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

Announcements
Want to see what's currently in public preview? We've pulled it all together in one place. Check it out here
cancel
Showing results for 
Search instead for 
Did you mean: 
saminouari
Contributor III
Contributor III

Sum If Aggr two dimensions

Hi,

In a table I have a dimension PDV_ModelCode which contains two completely different questions :

  • PDV_ModelCode={"presenceOUT"}, the value is a boolean data type
  • PDV_ModelCode={"presenceKo"}, the value is a enum data type

pdv.PNG

What I want is when PDV_ModelCode={"presenceOUT"} and PDV_Boolean={1} then Count or sum this formula PDV_ModelCode={"presenceKo"},  PDV_Enum={1}. I tried this script but it didn't work.

if(count({<PDV_ModelCode={"presenceOUT"}, PDV_Boolean={1}, StoreDisabled={0}>} StoreId&ProductId)>0,
count({<PDV_ModelName={"INTRO"}, PDV_Enum={1}, StoreDisabled={0}>} StoreId&ProductId))

 

Labels (1)
1 Reply
UserID2626
Partner - Creator III
Partner - Creator III

try in set expression.

if([PDV_ModelCode]={'presenceOUT'} and [PDV_Boolean]='1' and [StoreDisabled]='0',
count({<[PDV_ModelName]={'INTRO'}, [PDV_Enum]={'1'}, [StoreDisabled]={'0'}>} [StoreId])
+
count({<[PDV_ModelName]={'INTRO'}, [PDV_Enum]={'1'}, [StoreDisabled]={'0'}>} [ProductId])
)

 

if you want to do in script, you can try something like below

Sample_Table:

load * from table;

join

load dimension1,

dimension2,dimension3,...

Count(Store_ID) as XXX,

Count(Product_ID) as YYYY

resident Sample_Table

where [PDV_ModelCode]={'presenceOUT'} and [PDV_Boolean]='1' and [StoreDisabled]='0';