Skip to main content
Announcements
Qlik Connect 2025: 3 days of full immersion in data, analytics, and AI. May 13-15 | Orlando, FL: Learn More
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Complicated calculation in a chart

Hi All,

I try to calculate a revenue in a chart, but the logic makes it hard to implement:

  1. if PricingModel='CPA' then the revenue is Sum(PixelSum)*CPAGoal
  2. if PricingModel='CPC' then the revenue is Sum(Hits)*CPCRate

As it can be seen, the calculation depends on the row level, means that i need to calculate the Sum(PixelSum) for all rows that their PricingModel='CPA' (and then multiply the result with CPAGoal), and i need to calculate the Sum(Hits) for all rows that their PricingModel='CPC' (and then to multiply the result with CPCRate).

How do i let the chart "understand" the right calculation?

Thanks,

Guy

7 Replies
jagan
Luminary Alumni
Luminary Alumni

Hi,

Try this expression

=Sum(if(PricingModel='CPA', Sum(PixelSum)*CPAGoal, if(PricingModel='CPC', Sum(Hits)*CPCRate)))

OR

Sum({<PricingModel={'CPA'}>} Sum(PixelSum)*CPAGoal) + Sum({<PricingModel={'CPC'}>} Sum(Hits)*CPCRate)

Hope this helps you

Regards,

Jagan.

v_iyyappan
Specialist
Specialist

Hi,

     Try this expression like,

= (Sum({<PricingModel={'CPA'}>} PixelSum)* CPAGoal)  + (Sum({<PricingModel={'CPC'}>} Hits)* CPCRate)

Regards,

Iyyappan

Not applicable
Author

Hi v.iyyappan,

The problem is that when i uses this expresion in the chart it works only for specific dimensions. i need this calculation to be valid for any combination of dimensions.

Thanks,

Guy


v_iyyappan
Specialist
Specialist

Hi,

     can u attach a sample file. it helpful for us to solve your requirments.

Regards,

Iyyappan

vijay_iitkgp
Partner - Specialist
Partner - Specialist

Hi Guy,

As per your note the chart will work only for pricemodel CPA and CPC and all other dimensions related to these price model. If you need something more then please explain your requiremnt.

Regards

Vijay

Not applicable
Author

Hi iyyappan & Vijay,

I have already another new post with the same tilte and attached a QVW there.

By the way, the a solution was found.

Not applicable
Author