Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
qlikbbguser
Contributor II
Contributor II

How to retrieve the value from a field corresponding to the latest date

hello,

Here's the mockup of my data:

qlikbbguser_0-1724451919785.png

 

 

I wanted to

(1) create a calculation/expression to retrieve the value as of latest date based on the Date field, and put into a KPI chart as the measure.

(2) I also want the KPI box to be driven by the filter of Customer

So if I select Wholefoods in the filter, I want the 500 to be displayed in the KPI chart. 

How can I achieve this? Thank you !!!!

Labels (1)
1 Solution

Accepted Solutions
Digvijay_Singh

Try this also, much simpler - 

Max(Total<Date> Value)

View solution in original post

5 Replies
Frank_S
Support
Support

Here are a couple of solutions from the community:
 

https://community.qlik.com/t5/New-to-Qlik-Analytics/Max-Date/td-p/1812770

https://community.qlik.com/t5/App-Development/max-value-of-max-date/td-p/1821544

 

'Max" reference material:

https://help.qlik.com/en-US/cloud-services/Subsystems/Hub/Content/Sense_Hub/Scripting/AggregationFun...

 

Kind regards...

Please remember hit the 'Like' button and for helpful answers and resolutions, click on the 'Accept As Solution' button. Cheers!
Digvijay_Singh

May be this expression in KPI, works for me - 

Max(Aggr(firstsortedvalue(Aggr(Max(Value),Date),-Date),Customer))

Digvijay_Singh_1-1724472010153.png

 

 

Digvijay_Singh

Try this also, much simpler - 

Max(Total<Date> Value)

qlikbbguser
Contributor II
Contributor II
Author

hello! Thanks very much for your help. I tried both formula you gave but they didn't work unfortunately 😞
Attaching all the fields of data - could you help investigate?

So essentially I want the latest Sales Revenue to be displayed in the KPI chart, driven by the customer name chosen in a filter. The 'latest' is determined by the Qlik Date field.

-> Based on the data in attached file, I would want to show the 250 as my KPI if I select Whole Foods in my filter.


what I tried was:

 1. create an expression to convert Qlik Date field to date format, and name this new field [Qlik Date in Date Format]

 

qlikbbguser_0-1724506257480.png

2. Then i created another expression for Sales Revenue, and name this new field [Sales Revenue]:

qlikbbguser_1-1724506340936.png

 

3. Then I used your formula to calculate latest sales revenue:

qlikbbguser_2-1724506425084.png

 

My KPI chart shows '-' with customer filtered. 

 

 

Frank_S
Support
Support

The problem appears to be with your data.

1. ensure your source data is accurate (valid date and text fields in your excel file...general is used).

2. you may not have correct associative source data. Source data may be in invalid format.

3. when you have valid source data, ensure to concatenate your fields to create monthyear date values. (not shown in uploaded sample provided.

The solution provided by @Digvijay_Singh does work if used with valid source data. His code is used in the app uploaded here.

Frank_S_0-1724686170051.png

 

You may use the attached QVF to reverse engineer what was done.

Should you need further assistance, you may wish to reach out to one of our trusted Qlik Partners or Qlik Professional services to troubleshoot your source data.

Kind regards...well done @Digvijay_Singh 

 

Please remember hit the 'Like' button and for helpful answers and resolutions, click on the 'Accept As Solution' button. Cheers!