7 Replies Latest reply: Jun 26, 2018 11:54 AM by Sunny Talwar RSS

    Case when..?

    Raman Singh

      Hi,

       

      I am trying to get a calculation but not sure how to go about doing it in Qlik Sense.


      I have rows which I need to calculate in inches but some of the rows are in cm. How would I write the expression to say:


      Sum(case when type = 'cm' then length/2.54 else length end as length)

      Sum(case when type = 'cm' then height/2.54 else length end as length)

      Sum(case when type = 'cm' then width/2.54 else length end as length)

       

      I can then multiply together the above to get cubic inches.

       

      PartIDTypeLengthHeightWidthCubic Inches
      1cm10105=sum(10/2.54)*(10/2.54)*(5/2.54)
      2cm12105=sum(12/2.54)*(10/2.54)*(5/2.54)
      3inch555=sum(10)*(10)*(5)
      4inch10155=sum(10)*(10)*(5)
      5cm151010=sum(15/2.54)*(10/2.54)*(10/2.54)

       

      Thank you in advance for the help.