3 Replies Latest reply on May 1, 2018 1:19 PM by Deepak Rai

    How to divide a sum(if sales type = A then [sales]end) / sum(if sales type = B then [sales]end)?

    Ava Kingsley

      Hi Tableau Community,

       

      I have Sales Type as a dimension and there are two types - A & B. For each month, I would like to divide sales type A # sales divided by sales type B # sales. # Sales is my measure.

      I have the function:

      SUM(IF [SALES TYPE] = 'A' THEN [# SALES] END) / SUM(IF [SALES TYPE] = 'B' THEN [# SALES] END)

       

      I have date as my columns and I put this calc pill into the rows. When I do that it says "AGG(SALES A/B)" and shows up as all nulls.

       

      Is there any solution to this?

       

      Thanks,

      Ava