Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Zaga_69
Creator
Creator

Counting based on a condition

Hi guys!

I would like to count the Cost Center which meets the following condition:

sum({<CostElementFlagPur={1}, Scenario={'ACT'}, PPV_Type= >} Amount_GC )  /

sum({<CostElementFlagPur={1}, Scenario={'PY'}, PPV_Type= >} Amount_GC ))> 1

I tried sth like this:

if(
(sum({<CostElementFlagPur={1}, Scenario={'ACT'}, PPV_Type= >} Amount_GC )

/


sum({<CostElementFlagPur={1}, Scenario={'PY'}, PPV_Type= >} Amount_GC ))> 1 , count({<CostElementFlagPur={1}, PPV_Type=>} distinct CostCenter))

However, it does work, since it counts the total Cost Center and does not take into account the condition mentioned above.

Any Idea?

Many Thanks!

Edi

Labels (1)
5 Replies
Gysbert_Wassenaar
Partner - Champion III
Partner - Champion III

Try this:
count({<CostElementFlagPur={1}, PPV_Type=,CostCenter={"=sum({<CostElementFlagPur={1}, Scenario={'ACT'}, PPV_Type= >} Amount_GC ) / sum({<CostElementFlagPur={1}, Scenario={'PY'}, PPV_Type= >} Amount_GC ))> 1"} >} distinct CostCenter)

talk is cheap, supply exceeds demand
sergio0592
Specialist III
Specialist III

Hi,

Try with :

count({<CostCenter={"=sum({<CostElementFlagPur={1}, Scenario={'ACT'}, PPV_Type= >} Amount_GC ) /

sum({<CostElementFlagPur={1}, Scenario={'PY'}, PPV_Type= >} Amount_GC ))> 1"}>} CostCenter)

Zaga_69
Creator
Creator
Author

Hi Gysbert,

Thanks but it does not work. It just give me as result 0 

😕

Zaga_69
Creator
Creator
Author

Hi Sergio,

Thanks but it does not work. It just give me as result 0 

😕

Gysbert_Wassenaar
Partner - Champion III
Partner - Champion III

All the field names must be the exact case sensitive field names. If you then still get 0 then there are no CostCenter values that meet the condition you specified.

talk is cheap, supply exceeds demand