1 2 Previous Next 15 Replies Latest reply on Oct 4, 2017 10:15 AM by Kim Cataldo

    Mixing aggregate and non-aggregate IF statement - returns null

    Kim Cataldo

      Looking for input to fix the following formula:

       

      IF attr([Segment]) = "Consumer" THEN [Profit Ratio] ELSE 0 END

       

      Where Profit Ratio is an aggregated measure (SUM([Profit])/SUM([Sales]))

       

      The goal is to create an IF statement that returns the profit ratio for only the Consumer segment.  The formula above follows Tableau's solution for mixing aggregate and non-aggregate arguments within an if statement. (http://kb.tableau.com/articles/knowledgebase/calculation-error-resolving-aggregate-nonaggregate-arguments)

       

      The formula is valid however, it only works when the Segment dimension is present within the view, otherwise it returns a null.  (See attached workbook for example.)

       

      Thank you for any insight you can provide!

        1 2 Previous Next