Skip to main content
Announcements
Introducing a new Enhanced File Management feature in Qlik Cloud! GET THE DETAILS!
cancel
Showing results for 
Search instead for 
Did you mean: 
HugoBoyle
Contributor II
Contributor II

Show Max value based on Total of another field

I have a table coming into Qliksense where I am showing short deliveries.

Each of these short deliveries would have a reason for the shortage on the table.

In my app I want to show the reason description based on the reason with the highest shortage value.

 

Example:

Order     Date                   Shortage Qty            Reason

13001     01/02/2023     10                                   Out of Stock

13002     01/02/2023      1                                    Damaged Stock

14065     15/02/2023      3                                    Out of Stock

14523     19/02/2023      8                                    Damaged Stock

15001    01/03/2023       20                                 Damaged Stock

15015    13/03/2023       50                                 Damaged Stock

16001    01/04/2023       3                                    Damaged Stock

 

If the user selects to view orders in February 2023 I want to see a total out of stock of  22 with a reason of 'Out Stock' as 22 was the overall total for February and 'Out of stock' was the reason for most of these shortages in February (total 13).

If the user selects to view orders in February  and March 2023 I want to see a total out of stock of  92 with a reason of 'Damaged Stock' as 92 was the overall total for February and March and 'Damaged stock' was the reason for most of these shortages in February and March (total 79).

 

How can I code this in Qliksense ?

Labels (1)
1 Solution

Accepted Solutions
Oleg_Troyansky
Partner Ambassador/MVP
Partner Ambassador/MVP

Hi Hugo,

You are in luck 0 there is a function for that! Check out the function FirstSortedValue(). In your case, it should look like along these lines:

FirstSortedValue(Reason, -[Shortage Qty])

or 

FirstSortedValue(Reason, -sum([Shortage Qty]))

depending on the context. 

To learn more advanced development techniques, check out the agenda of the Masters Summit for Qlik - coming soon to Orlando and to Dublin!

 

View solution in original post

2 Replies
Oleg_Troyansky
Partner Ambassador/MVP
Partner Ambassador/MVP

Hi Hugo,

You are in luck 0 there is a function for that! Check out the function FirstSortedValue(). In your case, it should look like along these lines:

FirstSortedValue(Reason, -[Shortage Qty])

or 

FirstSortedValue(Reason, -sum([Shortage Qty]))

depending on the context. 

To learn more advanced development techniques, check out the agenda of the Masters Summit for Qlik - coming soon to Orlando and to Dublin!

 

HugoBoyle
Contributor II
Contributor II
Author

Perfect That worked. Many thanks.