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: 
Stevendf
Contributor
Contributor

How to use aggr() function with max date

I am new to Qlik Sense and have a simple problem that I couldn´t find any answers that fit my case:

I have a table like this:

Date_SalesValue
31/01/201910
31/01/201920
31/01/201930
28/02/201920
28/02/201930
28/02/201940
31/03/201915
31/03/201925
31/03/201935

 

I want to show in a KPI the sum of sales of the last date. In this case, last date is 31/03/2019 and the sum is 75.

The function that I came up was "=Max(aggr(sum([Value]),[Date_Sales.autoCalendar.YearMonth]))", but it´s, obviously incorrect, and only shows me the sum of the date 28/02/2019, which is 90 (max of the 3).

Any help for this? Sorry if it´s too simple. I started working on Qlik Sense this week and couldn´t find anything that helped me.

Thanks

1 Solution

Accepted Solutions
dplr-rn
Partner - Master III
Partner - Master III

try
Sum({<Date_Sales={'$(=Max(Date_Sales))'}>}Value)

View solution in original post

3 Replies
Vegar
MVP
MVP

image.pngRawData:
load  date#(Date_Sales, 'DD/MM/YYYY') as Date_Sales,
Value as Value 
inline [
Date_Sales,	Value
31/01/2019,10
31/01/2019,20
31/01/2019,30
28/02/2019,20
28/02/2019,30
28/02/2019,40
31/03/2019,15
31/03/2019,25
31/03/2019,35
];

With the script above you could use the following expression to get your 75.

=Sum({<Date_Sales = {"$(=Maxstring(Date_Sales))"}>}Value)

 

dplr-rn
Partner - Master III
Partner - Master III

try
Sum({<Date_Sales={'$(=Max(Date_Sales))'}>}Value)
Stevendf
Contributor
Contributor
Author

It worked perfectly. Thank you so much.