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: 
KMD
Contributor
Contributor

Set Analysis not working for Only on If condition

Hi,

I am looking to get different dimension values based on same ranking. So, I have created an inline view with Dim and Exp by assigning a value to each dim.

Load * Inline
[
dim, exp
'Style', '1'
'Colour', '2'
'Min Range of Month', '3'
'RRP', '4'

];

 And I am looking to bring the corresponding values thru if statement on Straight table

KMD_1-1713153506177.png

 

The below expression is not working as expected,

if(exp='1',only(if(Aggr(rank(sum(total <[Style Colour]> [Sales Amount]),4),[Style Colour]) = 1, [Style])),

if(exp='2', only(if(aggr(rank(sum(total <[Style Colour]> [Sales Amount]),4),[Style Colour]) = 1, [Colour])),

if(exp='3', only(if(aggr(rank(sum(total <[Style Colour]> [Sales Amount]),4),[Style Colour]) = 1, [Min Range Month])),
if(aggr(rank(sum(total <[Style Colour]> [Sales Amount]),4),[Style Colour]) = 1, Sum([Sales Amount]))
)
)
)

Can you please check my set analysis and advise why it's not working for other values. 

Thanks in advance.

Labels (1)
5 Replies
Anil_Babu_Samineni

This case you need reverse way against Dimension not expression, something like this

if(exp='1', If(dim='Style', ......) // Please remove Only(), not sure the usage for you.

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
KMD
Contributor
Contributor
Author

Thanks @Anil_Babu_Samineni ,

I even tried giving in the following way but still ending up with the same Answer.

KMD_0-1713171596193.png

 

if(dim='Style',only(if(aggr(rank(sum(total <[Style Colour]> [Sales Amount]),4),[Style Colour]) = 1, [Style])),

if(dim='Colour', only(if(aggr(rank(sum(total <[Style Colour]> [Sales Amount]),4),[Style Colour]) = 1, [Colour] )),
only(if(aggr(rank(sum(total <[Style Colour]> [Sales Amount]),4),[Style Colour]) = 1, [Min Range Month]))
)
)

And If I remove only () function it is not showing any values in the table. I believe with this only() I am able to match up the possible value as the calculated dimension.

Also I observe, the above expression works only when exp=1 or dim='Style', If I give any other value in the if condition as 1st one in the expression, it is showing all nulls instead of printing it beside Colour in dim.

if(dim='Colour', only(if(aggr(rank(sum(total <[Style Colour]> [Sales Amount]),4),[Style Colour]) = 1, [Colour] ))) 

KMD_1-1713172612155.png

Just wondering if there is anything wrong in considering the inline view?

 

Anil_Babu_Samineni

I guess, the condition is matching only to the first attribute. What this is returning as new expression in the same table?

only(if(aggr(rank(sum(total <[Style Colour]> [Sales Amount]),4),[Style Colour]) = 1, [Colour]))

 

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
KMD
Contributor
Contributor
Author

It's bringing up for only first attribute.

KMD_0-1713223519021.png

 

Anil_Babu_Samineni

please share some data set and application to check in detail. 

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful