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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Brites
Contributor II
Contributor II

FirstsortedValue of an aggregation

I am looking to display the latest value in a aggregation. Currently I am using an aggregation have the following information:

=aggr(Sum([Sales]),Week)

Week Sales
2020/01 10
2020/02 12
2020/03 1
2020/04 9
2020/05 8


Now i want to have a KPI which display only the latest sale value from the aggregation showed above.

The formula that i tried, and was not working is:

= FirstSortedValue(aggr(Sum([Sales]),Week),-Week)

1 Solution

Accepted Solutions
Or
MVP
MVP

You could use something along the lines of:

Sum({< [Week] = {"=$(=MaxString(Week))"}  >} Sales)

 

 

 

 

View solution in original post

3 Replies
Or
MVP
MVP

As far as I know, you can't use a text field for the sort_order portion of a FirstSortedValue() formula. You could work around this by creating a numeric/date week field instead of what appears to be a textual one.

Brites
Contributor II
Contributor II
Author

The list of words appears already sorted whenever i put it in a plot or table. So if there anyway for me to query an specific element of the aggregation, that would be enough for me, even if it does not involve the FirstSortedValue() function.

Or
MVP
MVP

You could use something along the lines of:

Sum({< [Week] = {"=$(=MaxString(Week))"}  >} Sales)