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

"For each" in expression

Hi,

I want to apply my IF formula to all the my field list :

if(
Material=Exclusion_Mat_PGI_Copy,Exclusion_LIVING_FLAG_SCOPE,

if(
Material<>Exclusion_Mat_PGI_Copy,LIVING_FLAG_SCOPE
))

Here it's stoping at one value.

 

Is there any equivalent of For Each that can I use it in my expressions please ?

Thank you in advance for your help.

Best regards, Arun

9 Replies
pradosh_thakur
Master II
Master II

Hi Arun,

 

A liitle back ground please. Is material and Exclusion_Mat_PGI_Copy are fields , what exactly are you looking for? In which object are yiu using it ?  Giving you an answer without context may not help you.

 

Thanks

Pradosh

Learning never stops.
MJ
Contributor
Contributor

Hi,

Try to put the values in quotes, i.e. Material='Exclusion_Mat_PGI_Copy'

Thanks

Monika

Ivan_Bozov
Luminary
Luminary

Shouldn't it be like:

IF(Material='Exclusion_Mat_PGI_Copy',  Exclusion_LIVING_FLAG_SCOPE, LIVING_FLAG_SCOPE)

You can also provide a sample data with expected outcome to make it easier for us.

vizmind.eu
arun2305
Contributor III
Contributor III
Author

Hi Pradosh Thakur,

Yes you are right...

Here is the Expression measure that I am using :

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

Here vExclusion_Scope it's a variable that is equal to :

if(
Material=Exclusion_Mat_PGI_Copy,Exclusion_LIVING_FLAG_SCOPE,

if(
Material<>Exclusion_Mat_PGI_Copy,LIVING_FLAG_SCOPE
))

Here "Material", "Exclusion_Mat_PGI_Copy", "Exclusion_LIVING_FLAG_SCOPE" and  "LIVING_FLAG_SCOPE" are fields.

There are duplicate values in the "Material" field.

The Expression measure, here stop calculating when he finds is firts Value...

I hope I have been clear.

Thank you again.

Best regards, Arun

pradosh_thakur
Master II
Master II

Try this first

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

Learning never stops.
arun2305
Contributor III
Contributor III
Author

Example.JPG

 

Here you can on the left you the numbers missing for the "ATR", "A330", and "BelugaXL". It  should be like the right one.

arun2305
Contributor III
Contributor III
Author

Exmple 2.JPG

 

 

 

 

 

No it's not working because as there are duplicate values in the field "Measure", please the picture above when I use sum( total aggr(if($(vExclusion_Scope)<>'NO',1,0),Material))

pradosh_thakur
Master II
Master II

As there are duplicates in Material field your expression is not calculating properly. Try the below then may be share a sample app, sample app can define your problem and need be the actual app with data

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

Learning never stops.
arun2305
Contributor III
Contributor III
Author

Here Pradosh,

I created a sample...

Thank you again for your help.

Best regards, Arun