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: 
Anonymous
Not applicable

How to use if stmt within sum function in set analysis?

I need the foll:

Fyear

GROUP_DESC

Amount

FY13

Net sales

2343

Profit

12%

FY12

Net sales

3452

Profit

23%

I am using Set analysis something like foll which is having four diff expressions and giving me four columns in the table:

sum({<GROUP_DESC={'Net sales'},FYear={$(vPrevFY)}>}Amount)/1000000

sum({<GROUP_DESC={'Net sales'},FYear={$(vCurrFY)}>}Amount)/1000000

sum({<GROUP_DESC={'Profit'},FYear={$(vPrevFY)}>}Amount)/1000000

sum({<GROUP_DESC={'Profit'},FYear={$(vCurrFY)}>}Amount)/1000000

how can i get all these four in one condition so that i get only one column using if stmt?

1 Solution

Accepted Solutions
jagan
Partner - Champion III
Partner - Champion III

Hi,

Try this

=sum({<GROUP_DESC={'Net sales', 'Profit'},FYear={$(vPrevFY), $(vCurrFY)}>}Amount)/1000000


Regards,

jagan.

View solution in original post

5 Replies
jagan
Partner - Champion III
Partner - Champion III

Hi,

Try this

=sum({<GROUP_DESC={'Net sales', 'Profit'},FYear={$(vPrevFY), $(vCurrFY)}>}Amount)/1000000


Regards,

jagan.

Anonymous
Not applicable
Author

Perfect!!!

Thanks a lot

Anonymous
Not applicable
Author

The only issue is that my Profit is not showing as %. How do I do that?

jagan
Partner - Champion III
Partner - Champion III

Hi,

Can you attach the sample file, so that it would be easier to understand.  If you have a dimension GROUP_DESC then try like this

=If(GROUP_DESC  = 'Profit', Num(sum({<GROUP_DESC={'Net sales', 'Profit'},FYear={$(vPrevFY), $(vCurrFY)}>}Amount)/1000000, '##0%'),  Num(sum({<GROUP_DESC={'Net sales', 'Profit'},FYear={$(vPrevFY), $(vCurrFY)}>}Amount)/1000000, '#,##0'))


Hope this helps you.


Regards,

Jagan.

Anonymous
Not applicable
Author

It does work for the Current year.. but not for previous year..

But really helpful in understanding

Thanks a lot!!!