Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

How to write expression based on condition?

Hi,

I have to write an expression in pivot table.

Dimension1: Label

Dimension2: Topper

Expression: Count(ID)

but the expression should need the condition as

If Label='Poppy' and Topper equal to any other value instead of Topper<>'Poppy' then the expression should show count(Id). how can I write the expression.

can anyone suggest me please.

Thanks.

1 Solution

Accepted Solutions
Gysbert_Wassenaar

count({< Label = {'Poppy'},Topper -= {'Poppy'} >}ID)


talk is cheap, supply exceeds demand

View solution in original post

10 Replies
Clever_Anjos
Employee
Employee

count(if(Label='Poppy' and Topper <> 'Poppy',Id)

Gysbert_Wassenaar

count({< Label = {'Poppy'},Topper -= {'Poppy'} >}ID)


talk is cheap, supply exceeds demand
Not applicable
Author

count({$< Label = {'Poppy'},Topper -= {'Poppy'} >}ID)

sarvjeet
Contributor III
Contributor III

You can achieve this in front end using expression:

count({< Label = {'Poppy'},Topper -= {'Poppy'} >} ID)

Or

you can handle this  in back end. Create another field in datamodel: Col1  with definition

if(Label='Poppy' and Topper <> 'Poppy',1,0)


In UI use expression Sum(Col1)


Aggregation is faster as compare to count with set analysis



-Sarvjeet

Not applicable
Author

Thanks.

I have a condition  where Label='ert','tyu','iop','pou','rew','ion','Tr' and Topper ='Divi','patch','Copy','po' then the expression should show count(Id).  will below expression work for it?

Dimension1: Label

Dimension2: Topper

Expression: Count({<Label={'ert','tyu','iop','pou','rew','ion','Tr'}

,Topper ={'Divi','patch','Copy','po'}>} ID)


PradeepReddy
Specialist II
Specialist II

try the below thing

Count({<Label={'Poppy'},Topper ={'*'}-{'Poppy'}>} ID)

Not applicable
Author

Thanks.

I have a condition  where Label='ert','tyu','iop','pou','rew','ion','Tr' and Topper ='Divi','patch','Copy','po' then the expression should show count(Id).  will below expression work for it?

Dimension1: Label

Dimension2: Topper

Expression: Count({<Label={'ert','tyu','iop','pou','rew','ion','Tr'}

,Topper ={'Divi','patch','Copy','po'}>} ID)

PradeepReddy
Specialist II
Specialist II

IF Your requirement is..

Counting the no.of ID's with Label='ert' 'tyu','iop','pou','rew','ion','Tr'  and  Topper ='Divi','patch','Copy','po'.

then whatever expression your writing is correct.

Not applicable
Author

Thanks.