Skip to main content
Announcements
Live today at 11 AM ET. Get your questions about Qlik Connect answered, or just listen in. SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
dominicanlauf
Contributor III
Contributor III

Sum if question

Hello everybody,

I have a table that deals with the number of produced pieces  and the reasons for error.

Another point is the consideration of samples. The number of samples depends on the number of produced pieces.

Allocation:

produced (>150, >280, >500,>1200) -> samples(8,13,20,32,50)

 

I tried to determine the result by an If -function.

If I use the formula for each order number, it works.

If(MPS_productionorder.amount > 1200, 50, if(MPS_productionorder.amount > 500, 32, if(MPS_productionorder.amount > 280, 20, if(MPS_productionorder.amount > 150, 13, 8))))

 

funktioniert_sample.PNG

But once I calculate the sum (by year/month) it doesn't work.

sum(If(MPS_productionorder.amount > 1200, 50, if(MPS_productionorder.amount > 500, 32, if(MPS_productionorder.amount > 280, 20, if(MPS_productionorder.amount > 150, 150, 8)))))

smaple_neu.PNG

Does anyone have an idea how I could solve the Problem?

Labels (2)
1 Solution

Accepted Solutions
marcus_sommer

I think you need to use an aggr() to enforce a calculation on the order number, for example with something like this (shortened the long fieldname):

sum(aggr(
pick(match(-1, amount > 1200, amount > 500, amount > 280, amount > 150, amount <= 150), 50, 32, 20, 13, 8),
Auftragsnummer))

- Marcus

View solution in original post

2 Replies
dominicanlauf
Contributor III
Contributor III
Author

P.S.: Doesn't work means the sum of samples is incorrect.

 

 

marcus_sommer

I think you need to use an aggr() to enforce a calculation on the order number, for example with something like this (shortened the long fieldname):

sum(aggr(
pick(match(-1, amount > 1200, amount > 500, amount > 280, amount > 150, amount <= 150), 50, 32, 20, 13, 8),
Auftragsnummer))

- Marcus