Esha
Esha

Reputation: 57

Calculated field affected the Grand Total in Tableau

Used a calculated field by using the window_max and window_min functions:

IF 
([eCPM]) = WINDOW_MAX(([eCPM])) 
THEN "Least efficient"  ////Red
ELSEIF [eCPM] = WINDOW_MIN(([eCPM]))
THEN "Most efficient CPM"  ///Green
ELSE "Neither"  ///Gray
END

But this also affected my Grand Total. I don't want any coloring in totals. How to handle this? (Solved)
Since my calculation is based upon eCPM, can only this column be highlighted as green rather entire row, without highlighting media cost and visits green as well?

enter image description here

Since my calculation is based upon eCPM, can only this column be highlighted as green rather entire row, without highlighting media cost and visits green as well?

Upvotes: 2

Views: 731

Answers (1)

Fabio Fantoni
Fabio Fantoni

Reputation: 3167

You just need to "wrap" you if statement with another one in order to handle the grand total using size which returns the number of rows in the partition.

Using the superstore you can create a calculated field like this:

// Handle Grand Total
IF SIZE() = 1 THEN "Neutral"
// Handle all other "rows"
ELSE
  IF sum([Sales]) = WINDOW_MAX(sum([Sales])) 
    THEN "Green"
  ELSEIF sum([Sales]) = WINDOW_MIN(sum([Sales]))
    THEN "Red"
  ELSE "Neutral"
  END
END

The result could look like this: enter image description here

Upvotes: 1

Related Questions