Skip to main content
Announcements
Accelerate Your Success: Fuel your data and AI journey with the right services, delivered by our experts. Learn More
cancel
Showing results for 
Search instead for 
Did you mean: 
Simon4
Creator
Creator

Excluding percentages in a KPI

Hi all,

 

I have made this KPI:

avg(aggr(FirstSortedValue({<Netpurchaseprice={"<0>0"}>} Netpurchaseprice/Quantity,- Datecreated)/FirstSortedValue({<Netpurchaseprice={"<0>0"}>} Netpurchaseprice/Quantity,Datecreated)-1,Itemcode))

 

It shows the price difference from first order date to last order date. Due to administrational errors some percentages per product are for example 200 000%. I want to filter out all the percentages that are above 500%. Is this possible?

Simon4_0-1666017987295.png

 

Thanks in advance,

 

Simon

Labels (1)
1 Solution

Accepted Solutions
Oleg_Troyansky
Partner Ambassador/MVP
Partner Ambassador/MVP

Hi Simon,

Yes, you can! Simply use the IF function inside of the AGGR() to only include those values that are less than 5. Something like this:

avg(
     aggr( IF(
                    FirstSortedValue({<Netpurchaseprice={"<0>0"}>} Netpurchaseprice/Quantity,
                    -Datecreated)/FirstSortedValue({<Netpurchaseprice={"<0>0"}>} 
                    Netpurchaseprice/Quantity,Datecreated)-1 < 5,

               FirstSortedValue({<Netpurchaseprice={"<0>0"}>} Netpurchaseprice/Quantity,- Datecreated)/FirstSortedValue({<Netpurchaseprice={"<0>0"}>} Netpurchaseprice/Quantity,Datecreated)-1
               )
     ,Itemcode)
)

If you'd like to learn more advanced development techniques, including advanced Set Analysis and AGGR(), join us at the Masters Summit for Qlik , coming to New Orleans on Nov 14-16. 

Cheers,

View solution in original post

3 Replies
Oleg_Troyansky
Partner Ambassador/MVP
Partner Ambassador/MVP

Hi Simon,

Yes, you can! Simply use the IF function inside of the AGGR() to only include those values that are less than 5. Something like this:

avg(
     aggr( IF(
                    FirstSortedValue({<Netpurchaseprice={"<0>0"}>} Netpurchaseprice/Quantity,
                    -Datecreated)/FirstSortedValue({<Netpurchaseprice={"<0>0"}>} 
                    Netpurchaseprice/Quantity,Datecreated)-1 < 5,

               FirstSortedValue({<Netpurchaseprice={"<0>0"}>} Netpurchaseprice/Quantity,- Datecreated)/FirstSortedValue({<Netpurchaseprice={"<0>0"}>} Netpurchaseprice/Quantity,Datecreated)-1
               )
     ,Itemcode)
)

If you'd like to learn more advanced development techniques, including advanced Set Analysis and AGGR(), join us at the Masters Summit for Qlik , coming to New Orleans on Nov 14-16. 

Cheers,

Simon4
Creator
Creator
Author

HI Oleg,

 

Thank you for the solution! I have a follow up question. I want to exclude 0 values and values of under -5 too. But the formula is not working. Is this possibile?

avg(
aggr( IF(
FirstSortedValue({<Netpurchaseprice={"<0>0"}>} Netpurchaseprice/Quantity,
-Datecreated)/FirstSortedValue({<Netpurchaseprice={"<0>0"}>}
Netpurchaseprice/Quantity,Datecreated)-1 >-5 and <5 and =0,

FirstSortedValue({<Netpurchaseprice={"<0>0"}>} Netpurchaseprice/Quantity,- Datecreated)/FirstSortedValue({<Netpurchaseprice={"<0>0"}>} Netpurchaseprice/Quantity,Datecreated)-1
)
,Itemcode)
)

 

Thank you for the invite, unfortunatly I will not be able to come 😞

 

Kind regards,

 

SV

Simon4
Creator
Creator
Author

Ignore my last comment. I have got it working. 

 

Cheers