Skip to main content
Announcements
Qlik Introduces a New Era of Visualization! READ ALL ABOUT IT
cancel
Showing results for 
Search instead for 
Did you mean: 
harjotsingh16
Contributor II
Contributor II

Sum for IF Statement

Hello All,

 

I need help on doin sum for below situation

1. Need to do Sum of "Total Cost", which is measured value saved in Master Item (Unit Price x Qty)

2. Condition If Column "Cost Type" = CS1, CS3, CS4, CS6,CS8,CS10 then do sum of Total Cost 

3. I want to show this in KPI

I am trying by expression 
if(([Cost Type]='CS1','CS3','CS4,'CS6','CS8','CS10'),[Total Cost] ,Null) BUT getting error.

Please assist if anyone know 

Labels (3)
3 Replies
Zapparoli
Creator II
Creator II

Hi @harjotsingh16 

You can use Set Analysis to solve this, like so:

sum({< [Cost Type]={'CS1','CS3','CS4,'CS6','CS8','CS10'} >} [Total Cost])

You can read more about set analysis here:

https://help.qlik.com/en-US/qlikview/May2023/Subsystems/Client/Content/QV_QlikView/ChartFunctions/Se...

Let me know if it helps.

-Zapparoli

Check my Youtube Channel for more Qlik Content
https://www.youtube.com/@ZappaAnalytics

harjotsingh16
Contributor II
Contributor II
Author

Hello @Zapparoli ,

Thanks for the revert

 

I tried with your suggestion but didn`t work, the catch is Total cost. I tried to reflect Master item in KPI individually to see overall amount but it is showing me zero.

I think the 2 columns Qty and UP has to do something. I am completely confused at this point. 

Zapparoli
Creator II
Creator II

Hey @harjotsingh16 

Sorry about that, I did not see you had two fields.

In this case, can you try calculating the Total Cost field into the script ? 

Like so:

[Unit Price]  * Qty as Total Cost

Then you can use the formula I provided you before.

-Zapparoli

Check my Youtube Channel for more Qlik Content
https://www.youtube.com/@ZappaAnalytics