Using If Statement With Aggregated Measures To Resolve Cannot Mix Aggregate And Non Aggregate Measures

Published: 09 Jun 2020
Last Modified Date: 10 Jun 2020


Using If statement with aggregated measures to resolve cannot mix aggregate and non aggregate measures. Example: Showing Profit ratio for selected date parameter


  • Tableau Desktop


Option 1:

Using ATTR (an attribute) function but making sure that it has a unique value when the calculation is aggregated in the view

Option 2:

Using Calculated field Profit ratio for selected date like below taking sum of each measure after the comparison:

SUM(IF ([Order Date])=([Select a date parameter]) THEN [Profit]END)

/SUM(IF ([Order Date])=([Select a date parameter]) THEN [Sales] END) 
Did this article resolve the issue?