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

Show Highest and Lowest Sales and Day in KPI

I have Dates and Sales Columns in my data. I need to show what day/date from previous week had highest sales and lowest sales and put these numbers in a text box (KPI). If anyone could help me with this, I highly appreciate your help.

Labels (4)
1 Solution

Accepted Solutions
vinieme12
Champion III
Champion III

As below

Lowest Sales

=FirstSortedValue( {< DDT = {">=$(=WeekStart(Max(DDT),-1))<=$(=WeekEnd(Max(DDT),-1))"} >} aggr(sum(Sales) & ' ON ' & DDT ,DDT) ,aggr(sum(Sales),DDT) )

 

Highest Sales

=FirstSortedValue( {< DDT = {">=$(=WeekStart(Max(DDT),-1))<=$(=WeekEnd(Max(DDT),-1))"} >} aggr(sum(Sales) & ' ON ' & DDT ,DDT) ,  -aggr(sum(Sales),DDT) )

 

Replace DDT  with your Datefield name

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.

View solution in original post

7 Replies
KGalloway
Creator II
Creator II

This may work:

KGalloway_0-1675203450610.png

 

The expressions in the KPI charts are 

Min(if(date >= weekstart(today() - 7) and date <= weekend(today() - 7), sales)) for the minimum

max(if(date >= weekstart(today() - 7) and date <= weekend(today() - 7), sales)) for the maximum

vinieme12
Champion III
Champion III

As below

Lowest Sales

=FirstSortedValue( {< DDT = {">=$(=WeekStart(Max(DDT),-1))<=$(=WeekEnd(Max(DDT),-1))"} >} aggr(sum(Sales) & ' ON ' & DDT ,DDT) ,aggr(sum(Sales),DDT) )

 

Highest Sales

=FirstSortedValue( {< DDT = {">=$(=WeekStart(Max(DDT),-1))<=$(=WeekEnd(Max(DDT),-1))"} >} aggr(sum(Sales) & ' ON ' & DDT ,DDT) ,  -aggr(sum(Sales),DDT) )

 

Replace DDT  with your Datefield name

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.
qlikwiz123
Creator III
Creator III
Author

@vinieme12  Great, this works. Thank you so much.

 

 

qlikwiz123
Creator III
Creator III
Author

@vinieme12  Is it possible to show the overall Day when the average sales are high or low?

 

If average sales are high on Wednesday, show Wed...like this.

vinieme12
Champion III
Champion III

Format the date part  using date()

 

=FirstSortedValue( {< DDT = {">=$(=WeekStart(Max(DDT),-1))<=$(=WeekEnd(Max(DDT),-1))"} >} aggr(sum(Sales) & ' ON ' & Date(DDT,'DDD , DD-MMM-YYYY')  ,DDT) ,aggr(sum(Sales),DDT) )

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.
qlikwiz123
Creator III
Creator III
Author

Hi @vinieme12  The values are showing '-' in case they have multiple dates with same Highest and lowest sales. How do I handle this?

qlikwiz123
Creator III
Creator III
Author

@vinieme12 

Not sure if you got a chance to look at my query. Was worried to see '-' and not ideal to show blanks when there are multiple values satisfying the calculation.