Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

if expression

Hey people,

I have got a question concerning the if-expression.
Let me tell you what I am using in my formula:

Dimension "group" with 5 values = group1, group2, group3, group4, group5
Each group consists of different articles with different values:
eg.
group1 : article 1 (value = kilogram), article 2 (value = pieces)
group2 : article 1 (value = kilogram)
group3 : article 1 (value = pieces), article 2 (value = bags)

Different values need different calculations:
if the value = kilogram I use sum(Kilogram)
if the value = anything else I use sum(Revenue)

The formule I am using works fine:

if( value = 'bags' or value = 'pieces', sum(Revenue), sum(Kilogram))


Problem: I only want to show group1, 2 and 3 (without having to select anything).


So I guess somewhere I will have to write: Group = {'group1, group2, group3'}

AND, I also need the subtotal of the different groups. So somewhere in the dimension tab I should use a aggr() I assume..?

Thanks a lot!

1 Solution

Accepted Solutions
CELAMBARASAN
Partner - Champion
Partner - Champion

May be like this

Sum({<value={'kilogram'}>}Kilogram) + Sum({<value-={'kilogram'}>} Revenue)

Hope it helps

Celambarasan

View solution in original post

7 Replies
nilesh_gangurde
Partner - Specialist
Partner - Specialist

Hi,

You can add calculated dimension and write the following script.

if( wildmatch(Group,'group1', 'group2', 'group3'),Group)

Hope this will help.

-Nilesh

Not applicable
Author


This one works just fine already. That's awesome thanks!

Just one small question though, it also gives me a 4th group called ' - ' and this is the sum of the groups 4 and 5.

How can I hide this 4th one?

MayilVahanan

Hi

TRY LIKE THIS

Properties->dimension -> tick the  Suppress when value is null option

Thanks & Regards, Mayil Vahanan R
Please close the thread by marking correct answer & give likes if you like the post.
CELAMBARASAN
Partner - Champion
Partner - Champion

May be like this

Sum({<value={'kilogram'}>}Kilogram) + Sum({<value-={'kilogram'}>} Revenue)

Hope it helps

Celambarasan

Not applicable
Author

Thanks this worked!

Not applicable
Author

Problem:

I should be using an aggr() somewhere, the subtotals are incorrect. How do I solve this?

Thanks!

Not applicable
Author

It works!! Thanks a lot man!

I used it in combination with the wildmatch in my dimension and it now does exactly what it should do

Works like a charm!