Skip to main content
Announcements
Qlik Introduces a New Era of Visualization! READ ALL ABOUT IT
cancel
Showing results for 
Search instead for 
Did you mean: 
Krish
Contributor III
Contributor III

Identify max date for every ID field.

Hi,

 I have a chart where I need to identify the row which contains the max date. 

Expression used:

if(Aggr(
Count({<[EVENT]={'AIR'},[Month Num]={'<=$(#vSelectedMonthNumber)'},[Start Date]= {"$(=Max([Start Date]))"},[Event Month]=>} DISTINCT [ID])
,[ID],[Start Date])>0,'Y')

Input:

ID Start Date
1 01/01/2023
1 10/01/2023
2 22/01/2023
3 15/12/2023
3 03/04/2023
4 10/19/2023

 

Output:

ID Start Date Expr
1 10/01/2023 Y
2 22/01/2023 Y
3 15/12/2023 Y
4 10/19/2023 Y

 

Labels (1)
8 Replies
udit_k
Partner - Creator II
Partner - Creator II

use below expression:-

Date(sum(total<ID>aggr(date(max([Start Date])),ID)))

udit_k_0-1688383440934.png

 

 

Krish
Contributor III
Contributor III
Author

@udit_k 

  Thanks for your response. The final output should display only the row which has max date. In above example, for ID 1, it should show 10/01/2023 which is the max date ( 1 row)  and for ID 2 10/01/2023 etc. I do not want to show 01/01/2023 row item.

udit_k
Partner - Creator II
Partner - Creator II

use below expression and uncheck Include zero value in data handling

aggr(date(max([Start Date])),ID)

udit_k_0-1688384713640.png

 

BrunPierre
Partner - Master
Partner - Master

@Krish I would do something like that in a script.

Data:
Load * Inline [
ID,Start Date
1, 01/01/2023
1, 10/01/2023
2, 22/01/2023
3, 15/12/2023
3, 03/04/2023
4, 10/19/2023];

Inner Join
LOAD ID,
Max("Start Date") as "Start Date",
'Y' as Expr

Resident Data
Group By ID;

Exit Script;

Krish
Contributor III
Contributor III
Author

I am using QlikView.  I tried this in the chart but it doesn't give the intended results.

if(date(Count(TOTAL<[ID]>aggr(date(max([Start Date])),[ID])))>0,'Y')

 

It still gives me 2 rows. 

Krish
Contributor III
Contributor III
Author

I need both rows for other calculations. I cannot make the changes in script level.

udit_k
Partner - Creator II
Partner - Creator II

use below exp in dimension :-

if(Date((aggr(date(max([Start Date])),[ID])))>0,'Y')

udit_k_0-1688393476165.png

 

BrunPierre
Partner - Master
Partner - Master

Format the date field properly,

BrunPierre_0-1688414893057.png

Then try this;

=Only(Aggr(If([Start Date] = Max(TOTAL <ID> [Start Date]),[Start Date]), ID, [Start Date]))