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

Set analysis field equals to dimension value

Hi all,

I have often read that “Set analysis does not evaluate data per dimension but once per chart”. However I know that this is not always the case.


I have the following table where the first 4 fields are dimensions and the last 2 fields are expressions:

    

DimensionsExpressions
CN Submission KeyCN Number   Old PartNew Part   Old Part Held StockNew Part Held Stock
E14250-D1-L1-05/02/2016-15:21:57E1425063606-0263606-03836899
E14250-D1-L1-05/02/2016-15:25:39E1425063606-0263606-03836899
E14250-D1-L1-05/02/2016-16:42:42E1425063606-0263606-03836899
E14250-D1-L1-11/02/2016-10:04:46E1425063606-0263606-03836899
E14250-D1-L1-24/02/2016-12:28:57E1425063606-0263606-03836899
E14250-D1-L1-01/03/2016-12:53:41E1425063606-0263606-03836899
E15264C-D1-L1-05/02/2016-16:26:33E15264C19040-0119040-0387318
E16025-D1-L1-17/02/2016-14:58:07E1602552582-0352582-04789786
E16025-D1-L1-18/02/2016-14:17:08E1602552582-0352582-04789786
S14035-D1-L1-05/02/2016-15:27:21S1403516335-0316335-04434761
S14035-D1-L1-05/02/2016-15:27:42S1403516335-0316335-04434761
S14035-D1-L1-05/02/2016-15:27:52S1403516335-0316335-04434761
S15031-D1-L1-05/02/2016-15:24:49S15031S63550-0363550-04426211

For the two expressions in the table above I want to write a set analysis similar to the one below:


=sum({$<PartID= [Old Part] }, StockHeldFlag = {'Y'}>} StockQuantityOnHand)

And

=sum({$<PartID= [New Part] }, StockHeldFlag = {'Y'}>} StockQuantityOnHand)

So if the old part for a particular row is 63606-02, I want to mimic the following expression (but obviously for each and every row in the graph):

=sum({$<PartID= {‘63606-02’} , StockHeldFlag = {'Y'}>} StockQuantityOnHand)

Is there a way how one can simply refer to the value of the corresponding dimension in an expression with set analysis?

Thanks Matt

18 Replies
Anonymous
Not applicable
Author

I am using set expression in Expression and it works fine. But when i use the same as Calculated Dimension, it says "Error in Calculated Dimension''

sunny_talwar

What are you trying? Can you share? You might need to wrap it around with Aggr() function

Anonymous
Not applicable
Author

I can't post the exact Set Expression but here is the outline:

if(sum({$<Demand={'New'}>}(QUANTITY)) = sum({$<Demand={'New','Old'}>}(QUANTITY)),

'All' & ' ' & '(Provided' & ' ' & ((sum({$<Demand={'Old'}>}(QUANTITY))/sum({$<Demand={'New','Old'}>}(QUANTITY)))*100) & '%' & ')',

and two more if's similar to the one above.

swuehl
MVP
MVP

That's exactely what you need to do when you want to use set analysis in a calculated dimension.

Set Analysis can only be applied to aggregation functions, and to  be able to use aggregation functions in a dimension, you need to use advanced aggregation.

For example

=Aggr(Only({<Product = {A}>} Customer), Customer)

sunny_talwar

What is the dimension you want to check the if statement on for your calculated dimension?

Aggr(if(sum({$<Demand={'New'}>}(QUANTITY)) = sum({$<Demand={'New','Old'}>}(QUANTITY)),

'All' & ' ' & '(Provided' & ' ' & ((sum({$<Demand={'Old'}>}(QUANTITY))/sum({$<Demand={'New','Old'}>}(QUANTITY)))*100) & '%' & ')', DimensionName)

Anonymous
Not applicable
Author

Sunny,

The purpose of this Set Analysis is to create a new Column. When I do this in Expressions, it works perfect. But I need to place this column with other Dimensions, not with Expressions.

sunny_talwar

What were the dimension you used when you were using this as a dimension?

Anonymous
Not applicable
Author

There are many dimensions which are straight up Columns coming from database

sunny_talwar

Can you try adding all of them where I have DimensionName separated by a comma (,):

Aggr(if(sum({$<Demand={'New'}>}(QUANTITY)) = sum({$<Demand={'New','Old'}>}(QUANTITY)),

'All' & ' ' & '(Provided' & ' ' & ((sum({$<Demand={'Old'}>}(QUANTITY))/sum({$<Demand={'New','Old'}>}(QUANTITY)))*100) & '%' & ')', DimensionName)

Also it would be better if you can start a new thread for your question. It is not nice for us to spam somebody else unfinished business.