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

Expression with set analysis gives wrong calculation

Hi all,

I'm struggling with an expression that includes set analysis.

I want to calculate the amount of colli and by using the set analysis statement I want to exclude some Articles

= sum({$<[WH_Cd] -= {12}, [Rec_Article]={">99999","<>4859696"}, [Aisle_Facturation] -= {DISPLAY, EMPTIES}>}[Rec_Colli])

This works but when I want to exclude another Rec_Article the calculations are wrong.

= sum({$<[WH_Cd] -= {12}, [Rec_Article]={">99999","<>4859696","<>5797143"}, [Aisle_Facturation] -= {DISPLAY, EMPTIES}, [Vendor_Nbr] -= {"0014038"}>}[Rec_Colli])


I've calculated all the colli for Rec_Article 5797143 and the sum is 1340.

This should be extracted from the total on dimension Aisle_Desc.

This should be done for 2 expressions: #Colli and #Pallets

This is the situation before the exclude of Rec_Article 5797143 (which belongs to Aisle_Desc 'Mosselen_Zuurwaren')  

Aisle_Desc#Colli#PalletsAvg_IN
GRF422.37910.03342,10
Industrieel_Brood22.86996823,63
Mosselen_Zuurwaren45.3431.01144,85
PAT2.42017014,24
PBL_Traiteur214.3066.52532,84
PBL_Vlees192.3119.93319,36
PBL_Zuivel543.28717.56430,93
PBS_Traiteur77.6811.79543,28
Zuivel_Gekoeld196.7752.71572,48
Zuivel_Ongekoeld88.5983.00529,48
Total1.805.96953.71933,62

The sum for Rec_Article 5797143 is

Aisle_Desc#Colli#PalletsAvg_IN
Mosselen_Zuurwaren1.3403446,67
Total1.3403446,67

So the situation after the exclude should be:   

Aisle_Desc#Colli#PalletsAvg_IN
GRF422.37910.03342,10
Industrieel_Brood22.86996823,63
Mosselen_Zuurwaren44.0031.00843,65
PAT2.42017014,24
PBL_Traiteur214.3066.52532,84
PBL_Vlees192.3119.93319,36
PBL_Zuivel543.28717.56430,93
PBS_Traiteur77.6811.79543,28
Zuivel_Gekoeld196.7752.71572,48
Zuivel_Ongekoeld88.5983.00529,48
Total1.804.62953.71633,60

And this is the result I'm getting and I've highlighted the calculations that are wrong in red:

  

Aisle_Desc#Colli#PalletsAvg_IN
GRF413.4379.91842,10
Industrieel_Brood22.86996823,63
Mosselen_Zuurwaren42.93897843,90
PAT2.42017014,24
PBL_Traiteur214.3066.52532,84
PBL_Vlees192.1499.91319,38
PBL_Zuivel542.34917.52030,96
PBS_Traiteur77.4411.79143,24
Zuivel_Gekoeld196.7752.71572,48
Zuivel_Ongekoeld88.5983.00529,48
Total1.793.28253.503

33,52

Does anyone know what I'm doing wrong please?

Kind regards,

Monique

1 Solution

Accepted Solutions
sunny_talwar

Try this

=Sum({$<[WH_Cd] -= {12}, [Rec_Article]={">99999"}-{'4859696', '5797143'}, [Aisle_Facturation] -= {DISPLAY, EMPTIES}>}[Rec_Colli])

View solution in original post

8 Replies
sunny_talwar

Try this

=Sum({$<[WH_Cd] -= {12}, [Rec_Article]={">99999"}-{'4859696', '5797143'}, [Aisle_Facturation] -= {DISPLAY, EMPTIES}>}[Rec_Colli])

amber2000
Creator
Creator
Author

Thanks again Sunny,

Why does the expression [Rec_Article]={">99999","<>4859696","<>5797143"} not work?

This worked fine: [Rec_Article]={">99999","<>4859696"}


Monique

sunny_talwar

I am not sure, but may be swuehl‌ can answer this

swuehl
MVP
MVP

Are you 100% sure this one worked?

[Rec_Article]={">99999","<>4859696"}


I can imagine this does also not work as requested, for several reasons.

amber2000
Creator
Creator
Author

I'm not 100% sure but it must work because I can't find any data for that set.

Can you also tell me what the reasons are that it can't work please?

swuehl
MVP
MVP

a) The field value list of your set modifier combines the elements with OR logic, not AND logic.

Your first element is a search that returns values larger than 99999, your second search is suppossed to exclude 4859696 (or to return any other value).

This can't work as intended with the default OR logic (if I understand your intention correctly).

b) a search "<>4859696" does not mean 'not equal 4859696'.

It's a numeric search "<limit_1_numerical_value>limit_2_numerical_value"

where you are missing the limit_1_numerical_value. I believe that Qlik will just ignore the first comparison operator then, so your search should equal ">4859696".

If you would use "<4859696>4859696", then this may return values to the value list excluding 4859696, but still finding a) would put 4859696 back in the list due to the first search that returns all values larger than 99999 (assuming that 4859696 is a possible field value).

You should be able to test both findings with some numeric sample data.

sunny_talwar

Now that you have explained it in great detail... it all makes sense. Thanks swuehl

amber2000
Creator
Creator
Author

Sorry for the late reaction (I was on holiday).

Thank you Stefan for the detailed explanation.

For the less experienced developers this is very useful and educative information.

Also thanks to you Sunny for bringing this to Stefan's attention.

Kind regards,

Monique