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

Announcements
Qlik and ServiceNow Partner to Bring Trusted Enterprise Context into AI-Powered Workflows. Learn More!
cancel
Showing results for 
Search instead for 
Did you mean: 
arun2305
Contributor III
Contributor III

Count if with a varaible condition

Hi,

I want to measure a number of "Oders" with a variable condition.

Exmepl 33.JPG

count({$<$(vExclusion_Scope)={'YES'}>} Order)

Here "vExclusion_Scope" is a variable were you have "YES" and "NO" as values. And "Order" is a field name.

The formula isn't working, I don't know why ?

Can you please help me with ?

Thank you in advance for your help.

Best regards, Arun

18 Replies
arun2305
Contributor III
Contributor III
Author

@pradosh_thakur 

Here it's my variable value "vExclusion_Scope":

if(
Material=Exclusion_Mat_PGI_Copy,Exclusion_LIVING_FLAG_SCOPE,

if(
Material<>Exclusion_Mat_PGI_Copy,LIVING_FLAG_SCOPE
))

Here "Material" and "Exclusion_Mat_PGI_Copy" are a field. Where the field values are material number and can have duplicates values.

"Exclusion_LIVING_FLAG_SCOPE" and "LIVING_FLAG_SCOPE" are a field. Where there are two values "YES" or "NO" that's all.

arun2305
Contributor III
Contributor III
Author

@vishsaggi 

It's giving me the same result as @pradosh_thakur  formula...

vishsaggi
Champion III
Champion III

Can you change your variable expr like below with and equals to sign "=" :
After you open variable overview write like
= if(Material=Exclusion_Mat_PGI_Copy,Exclusion_LIVING_FLAG_SCOPE,LIVING_FLAG_SCOPE)
Then try using this variable in your set as Pradosh suggested.
arun2305
Contributor III
Contributor III
Author

@vishsaggi 

No it's not working either, the result is "0" this time...

vishsaggi
Champion III
Champion III

Can you share this sample qvw file if possible to quickly check whats happening ?
pradosh_thakur
Master II
Master II

I am sorry i am not getting notification so missed your comments.

as @vishsaggi  already mentioned put an '=' in your variable

=if(
Material=Exclusion_Mat_PGI_Copy,Exclusion_LIVING_FLAG_SCOPE,

if(
Material<>Exclusion_Mat_PGI_Copy,LIVING_FLAG_SCOPE
))

notice i have put an '=' in the variable, then sue the formula that we asked you to use

count({<Order={"=$(vExclusion_Scope)='YES' "}>}Order)

if that too doen't work, remove the equal to from the variable and try

count({<Order={"=$(=$(vExclusion_Scope))='YES' "}>}Order)
Learning never stops.
arun2305
Contributor III
Contributor III
Author

@pradosh_thakur 

No it's yet working with either of the formula's...

I don't know why...

Maybe I should use a "sum" Formula, like this :

sum(aggr(if($(vExclusion_Scope)<>'NO',1,0),Order))

pradosh_thakur
Master II
Master II

Yes please try .

 

Can you put  a screenshot of your variable expression again

Learning never stops.
arun2305
Contributor III
Contributor III
Author

@pradosh_thakur 

Sorry for the delay, I did not receive a notification.

It's not working...

Here it's my variable value :

exemple 2455.JPG

The "sum" formula take all the orders.

And I don't know why the formula below it's given me "0" as result, it should be correct :

count({<Order={"=$(=$(vExclusion_Scope))='YES' "}>}Order)