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: 
jerryr125
Creator III
Creator III

Displaying the most recent months data in a KPI

Hi - I have quantity data an I would like to display the most recent month's data value in a KPI - once the Month/Years are selected.

I tried this - no luck:

firstsortedvalue(QuantitySold,-[SalesDate.autoCalendar.YearMonth])

 

thoughts ? Jerry

4 Replies
marpet
Partner - Contributor II
Partner - Contributor II

Sum({<[SalesDate.autoCalendar.YearMonth]={"$(=Max([SalesDate.autoCalendar.YearMonth]))"}, [SalesDate.autoCalendar.Year]=, [SalesDate.autoCalendar.Month]=>}QuantitySold)

jerryr125
Creator III
Creator III
Author

Hi - unfortunately that did not work.

Example - if I select the following months:

Feb 2016 : Quantity Sold 3,157

May 2016 : Quantity Sold 11,379

April 2016 :Quantity Sold 11,609

The most recent month  = 11,609

It is displaying zero

thoughts ? Jerry

jerryr125
Creator III
Creator III
Author

Hi again -

I have been experimenting around this the firstsortedvalue

 

firstsortedvalue(TOTAL([QuantitySold]),-[SalesDate])

 

Returns a value of 6

Which in fact is the quantity sold for last day of the month.

I need to show the total for the entire month.

How ? 

 

thi_pham
Creator III
Creator III

I found autocalendar don't work in set analysis and some qlik functions sometimes.

This might help: 

sum({<SalesDate={">=$(=MonthStart(Max(SalesDate))) <= $(=MonthEnd(Max(SalesDate)))"}>} SalesDate

If you want to get current month:

sum({<[SalesDate.autoCalendar.MonthsAgo]={0}>} QuantitySold)

or

sum(if ([SalesDate.autoCalendar.MonthsAgo] = 0 , QuantitySold, 0))