Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

How to sum by dimension and divide by a different dimension value.

I have a table which is set up like this:

Claim        State     Payment_Type     Amount

  1              PA          Expert                   10

   1             PA          Loss                    15

    1            PA          Legal                    20

  2              PA          Expert                   5

   2             PA          Loss                    25

    2            PA          Legal                    20

I'd like to create a chart showing the sum of "amount" for "payment type" Expert and Legal divided by the sum of "amount" for "payment type" Loss.  For example, for State = PA, Payment_Type = Expert :   (10+5) / (15+25)

With Payment_Type as one of the dimensions in my stacked bar chart, I tried:    Sum(Amount) / Sum(if(Payment_Type = "Loss",Amount))  but this doesn't work properly. 

1 Reply
marcus_sommer

Try something like this:

sum({< Payment_Type = {'Expert'} >} Amount) / sum({< Payment_Type = {'Loss'} >} Amount)

- Marcus