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

Announcements
Join us in Bucharest on Sept 18th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
cleblois
Contributor III
Contributor III

How to sum values only when they are above a certain level

Hi,

I'm trying to make calculation on Part Numbers only if their total quantities are above a certain value.

Threshold value is in a variable (vLower)

Measure below is sending figures that are not what I expect. I suspect it to sum only unit Quantity above the threshold.

=Sum(if(PN=aggr(if(sum(Quantity)>=$(vLower), PN), PN), Quantity))

Notes

* for testing I created below dimension to flag the PN I had an interet in. This works

=aggr(if(sum(Quantity)>=$(vLower), DPN), DPN)

* I also tried to build a set but with no success

=Sum({<PN=P({<PN={"aggr(if(sum(Quantity)>=$(vLower), PN)"}>} PN)>} Quantity)

Any help or hint would be more than welcomed

Thx

C.

1 Solution

Accepted Solutions
Oleg_Troyansky
Partner Ambassador/MVP
Partner Ambassador/MVP

Hi Christophe,

I think you are overly complicating your solution. All you need is a static dimension PN (no need to create a dynamically calculated dimension, just let QlikView filter the dimension values based on the Expression).

In the expression, you just need a Set Analysis with an Advanced Search filter like this (just edited it, it wasn't simplified enough...):

=Sum({<PN={"=sum(Quantity)>=$(vLower)"}>} Quantity)


- You don't need AGGR, because a filter on the field PN serves as an implied AGGR by PN

- Your don't need an IF statement, because the Advanced Search, enclosed in double quotes and starting with the equal sign {"=..."}, serves as a condition.

This is it. It's actually a lot simpler than you thought.


Cheers,

Oleg Troyansky

Upgrade your Qlik skills at the Masters Summit for Qlik - coming soon to Milan, Italy!

View solution in original post

4 Replies
Oleg_Troyansky
Partner Ambassador/MVP
Partner Ambassador/MVP

Hi Christophe,

I think you are overly complicating your solution. All you need is a static dimension PN (no need to create a dynamically calculated dimension, just let QlikView filter the dimension values based on the Expression).

In the expression, you just need a Set Analysis with an Advanced Search filter like this (just edited it, it wasn't simplified enough...):

=Sum({<PN={"=sum(Quantity)>=$(vLower)"}>} Quantity)


- You don't need AGGR, because a filter on the field PN serves as an implied AGGR by PN

- Your don't need an IF statement, because the Advanced Search, enclosed in double quotes and starting with the equal sign {"=..."}, serves as a condition.

This is it. It's actually a lot simpler than you thought.


Cheers,

Oleg Troyansky

Upgrade your Qlik skills at the Masters Summit for Qlik - coming soon to Milan, Italy!

cleblois
Contributor III
Contributor III
Author

You're great! I spent the afternoon on this ...

Just one copy paste correction: =Sum({<PN={<PN={"=sum(Quantity)>=$(vLower)"}>} Quantity)

Thx,

MK_QSL
MVP
MVP

=SUM({<PN = {"=SUM(Quantity) >= $(vLower)"}>}Quantity)

Oleg_Troyansky
Partner Ambassador/MVP
Partner Ambassador/MVP

Yeah, I copied your formula and I didn't remove enough 🙂 thanks to Manish for correcting it!