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

Announcements
Join us to spark ideas for how to put the latest capabilities into action. Register here!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

% of total If statement

Hello All,

I have this IF statement- If([SERVICE LINE]='PF HOSPITALIST', sum(CASES), sum([ADJSTD CASES]))

How can I take the % of total of the IF statement? Do I have to enter this into the script or is there something I can do in the chart type.

So it would read Sum(IF statement)/ Sum( Total IF Statement).

Thanks,

EK

6 Replies
Gysbert_Wassenaar
Partner - Champion III
Partner - Champion III

In some chart types you can check the Relative option for the expression. That should give you the percentages of the total. This is not possible in pivot tables.


talk is cheap, supply exceeds demand
Not applicable
Author

Right..pivot table is the chart type I need for this...

Gysbert_Wassenaar
Partner - Champion III
Partner - Champion III

Of course you do. People always need the most bothersome option available.

Maybe like this then:

If([SERVICE LINE]='PF HOSPITALIST', sum(CASES), sum([ADJSTD CASES])) / (sum({<[SERVICE LINE]={'PF HOSPITALIST'}>} total CASES) + sum({<[SERVICE LINE]-={'PF HOSPITALIST'}>} total ADJSTD CASES))


talk is cheap, supply exceeds demand
Not applicable
Author

I try to be difficult . So close! The formula doesn't like the -= sign so anytime a selection is made when I need to use ADJSTD CASES the % is incorrect.

Gysbert_Wassenaar
Partner - Champion III
Partner - Champion III

That's a bug in the editor. The -= is correct syntax.


talk is cheap, supply exceeds demand
Not applicable
Author

Yea I know sometimes the syntax after will be underlined in red but the formula will work correctly. In this case though when no selections are made it shows 57% as total when it should be 100%. Anytime a selection is made when it is suming ADJSTD CASES it is incorrect. When it is suming CASES it is correct.