4
votes

In Tableau, I am trying to implement the following normalization logic:

https://stats.stackexchange.com/questions/70801/how-to-normalize-data-to-0-1-range

Basically, I want to take all values from a particular measure and scale them to values in the range of [0, 1]. This requires gathering the minimum and the maximum of a measure. What I want is...

(x - min(x)) / (max(x) - min(x))

If you create a calculated field using the above link's method, you get the "Cannot mix aggregate and non-aggregate" error.

This is where I am stuck. Is there a function and/or trick to get this to work?

2
did you try attr(x) for aggregating the first instance of the variable?astro11
ATTR(x) would only work if x is always the same value.glonn

2 Answers

4
votes

You need to use LOD expressions to tell Tableau that you want the min of all the x values, not just that row. Try:

    (x -{FIXED : MIN(x)})
    /
    ({FIXED  : MAX(x)}-{FIXED  : MIN(x)})
2
votes

You can try something like

(MEDIAN(X)- TOTAL(MIN(X))) / (TOTAL(MAX(X)) - TOTAL(MIN(X))). 

If the function only acts on one data point at a time, MEDIAN(X) will just return the value of the data point itself.