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

Announcements
Join us in Bucharest on Sept 18th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
jduarte12
Partner - Creator II
Partner - Creator II

Conditional expression based on different dimension attributes

Hi,

I have a table with the following information:

Dimension | Attribute | Value

A                    | 1                  | x

B                    | 2                  | 100

C                    | 2                  | 200

D                    | 3                  | 50

 

Where attribute and value are expressions. I need that for dimension with attribute=1, value being calculate upon the sum of values where attribute=2. In this case, x should be equal to 300.

I am trying with the following expression:

if(attribute=1, sum({1<attribute={2}>} value), sum(value))

However, I am getting x=0. I have not worked with Qlik for some time and I might be missing some very straightforward point. Can you please help?

 

Thanks in advance,

João

Labels (2)
1 Solution

Accepted Solutions
MayilVahanan

Hi,

You can assign the value in the variable and use it in the expression like

vAttribute1 = Sum({1<Attribute={2}>} Value)

if(Attribute=1, $(vAttribute1), sum(Value))

Hope it helps

Output:

mayilvahanan_0-1602749603661.png

 

 

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

View solution in original post

3 Replies
MayilVahanan

Hi,

You can assign the value in the variable and use it in the expression like

vAttribute1 = Sum({1<Attribute={2}>} Value)

if(Attribute=1, $(vAttribute1), sum(Value))

Hope it helps

Output:

mayilvahanan_0-1602749603661.png

 

 

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

Thank you! It solved the problem.

ElnurQV
Contributor
Contributor

Hi MayilVahanan,

 

I have similar question. I have the following table, where I would like the scenario A to take numbers from scenario B.

 

Scenario | Value 

A                    | 0              

B                    | 200                 

C                    | 250               

D                    | 300      

 

So as a result, scenario A would return 200.        

I used your logic as a new expression but did not work. Rather scenario A remained 0 and scenario B remained 200.Might you have any idea how I may do that?