Skip to main content
Announcements
NEW: Seamless Public Data Sharing with Qlik's New Anonymous Access Capability: TELL ME MORE!
cancel
Showing results for 
Search instead for 
Did you mean: 
madmax88
Creator II
Creator II

Condition in Expression

Hi,

I have a problem with an expression in set analysis. I have 3 Dimension (Customer, Product A, Product B) and a Value . e.g.

Customer, Product A, Product B

M, ,5

P,5,10

T, , 

Now I need an expression which sum the Value of Dimension B If the Value of Dimension A is null, else it should take the Value of B or null if both dimension don't have any value. 

Is this possible?

1 Solution

Accepted Solutions
danilodalosse
Partner - Contributor III
Partner - Contributor III

@madmax88 

if worked it's ok, but I'm not sure after to see your data.

Try to use like this bellow please. I believe to be better 

Count({<Product={B},CUST_ID={"=sum(Aggr(Count({<Product-={B}>}CUST_ID),CUST_ID))=0"}>}Distinct CUST_ID)

View solution in original post

8 Replies
Seyko
Partner - Creator
Partner - Creator

Hello,
Can you show us your expression?
cordially.
Excuse my english, i'm french!
danilodalosse
Partner - Contributor III
Partner - Contributor III

Hi @madmax88 ,

sum({<[Product A]={"=Len([Product A])=0"}>}[Product B])

bhargav_bhat
Creator II
Creator II

Can you share sample data and the output you require
Thanks,
Bhargav
madmax88
Creator II
Creator II
Author

Hi,

There are is my expression which is not working:

IF((Count({$<Product={'A'}>} Distinct(CUST_ID))>0,0,Count({$<Product={'B'}>} Distinct(CUST_ID)))

Example Data: Result should be 2 (Cust 4 and 5 only have Product B and not A, but Cust 3 has both product and therefor nothing should be counted for Cust 3.

CUST_IDProductOrder ID
1A12
2A13
3B14
3A15
4B16
5B17
6A18

 

madmax88
Creator II
Creator II
Author

this worked with one adaption 😉

(Count({$<[Product]={"len(A)=0"},[Product]={'B'} >} Distinct(CUST_ID))
danilodalosse
Partner - Contributor III
Partner - Contributor III

@madmax88 

if worked it's ok, but I'm not sure after to see your data.

Try to use like this bellow please. I believe to be better 

Count({<Product={B},CUST_ID={"=sum(Aggr(Count({<Product-={B}>}CUST_ID),CUST_ID))=0"}>}Distinct CUST_ID)

madmax88
Creator II
Creator II
Author

You're right. It seems not to work after checking detail data. It took me now both (A and B). 

With ur new expression it works, Thanks!

 

 

danilodalosse
Partner - Contributor III
Partner - Contributor III

Very good! Tks