Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
eloisateixeira
Contributor II
Contributor II

Show max date in dimension

Hi guys,

I have a table that show my products

PRODUCTDATETOTAL
A01/02/2018300
A05/02/2019140
B01/02/2015200
C08/03/2019500

 

I would like to show just the max date that we bought the product "A", same this:

PRODUCTDATETOTAL
A05/02/2019140
B01/02/2015200
C08/03/2019500
1 Solution

Accepted Solutions
tresesco
MVP
MVP

Why not just get max date from an expression, like:

Dimension : PRODUCT

Exp1: Date(Max(DATE))

Exp2: FirstSortedValue( TOTAL,  -DATE)

 

Note: If you have multiple transactions for max dates, you might have to use sum() along with aggr() within firstsortedvalue().

View solution in original post

2 Replies
Stoyan_Terziev
Partner - Creator III
Partner - Creator III

Hey Eliosa,

 

Here's the code that'll do that for you.

	Data:	// Entry Dataset
	LOAD
		PRODUCT,
		TOTAL,
	 	Date(Date#(DATE, 'DD/MM/YYYY'), 'DD/MM/YYYY') as DATE	//Here we make sure the dateformat is clearly identified
	;
	LOAD * INLINE [
	    PRODUCT, DATE, TOTAL
	    A, 01/02/2018, 300
	    A, 05/02/2019, 140
	    B, 01/02/2015, 200
	    C, 08/03/2019, 500
	];


	INNER JOIN(Data)	//We filter the input table to only the Max Date values per Product
	LOAD
		PRODUCT, 
		Date(Max(DATE), 'DD/MM/YYYY') as DATE
	RESIDENT Data
	GROUP BY
		PRODUCT
	;

I hope that helps!

 

Kind regards,

S.T.

tresesco
MVP
MVP

Why not just get max date from an expression, like:

Dimension : PRODUCT

Exp1: Date(Max(DATE))

Exp2: FirstSortedValue( TOTAL,  -DATE)

 

Note: If you have multiple transactions for max dates, you might have to use sum() along with aggr() within firstsortedvalue().