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: 
Anonymous
Not applicable

Getting Maximum Date Values in Table or a chart

Consider 3 fields from a table.

NameDateProfit
a11/20/2016100
a11/22/2016200
a11/23/2016230
b11/20/2016454
b11/20/2016690
b11/22/2016500
c11/19/2016123
c11/20/2016333
c11/21/2016140

I need to get only those names with maximum ( latest date) with those profit in another table or in a chart.

O/P:

NameDateProfit
a11/23/2016230
b11/22/2016500
c11/21/2016140

Please help in getting this.

Thanks

1 Solution

Accepted Solutions
trdandamudi
Master II
Master II

One more option is doing it in the dimension tab as below... Please see the attached:

Straight Table:

Dimenson:

Name

Dimension: <--- Date

=Aggr(FirstSortedValue(Date,-Date),Name)

Dimension: <---- Profit

=Aggr(FirstSortedValue(Profit,-Date),Name)

View solution in original post

9 Replies
trdandamudi
Master II
Master II

May be as below:

Dimension:

Name

Expression:   <--- Date Column

FirstSortedValue(Date,-Date)

Expression:  <----- Profit Column

FirstSortedValue(Profit,-Date)

giakoum
Partner - Master II
Partner - Master II

Try FirstSortedValue

trdandamudi
Master II
Master II

One more option is doing it in the dimension tab as below... Please see the attached:

Straight Table:

Dimenson:

Name

Dimension: <--- Date

=Aggr(FirstSortedValue(Date,-Date),Name)

Dimension: <---- Profit

=Aggr(FirstSortedValue(Profit,-Date),Name)

Anonymous
Not applicable
Author

Thanks for your help

can you please explain how this expression works?

Anonymous
Not applicable
Author

And what if i want to display the Second maximum date from the table

Like below,

NameDateProfit
a11/22/2016200
trdandamudi
Master II
Master II

If you want to get the second maximum then change the expressions as below:

=FirstSortedValue(Date,-Date,2)

=FirstSortedValue(Profit,-Date,2)

Anonymous
Not applicable
Author

Very thanks.. i got it..

Thank for your help..

trdandamudi
Master II
Master II

Returns the first value of expression sorted by corresponding sort-weight when expression is iterated over a number of records as defined by a group by clause.

In your case you need maximum 'Date'. So you need to add ' - ' to the date field to sort in the descending order, so that you get your maximum date.. If you don't add the ' - ' it will sort Ascending and you will get minimum date.

=FirstSortedValue(Date,-Date)

Please look on the community for few examples on FirstSortedValue... Hope this helps...

trdandamudi
Master II
Master II

You are welcome and I am glad it helped... If you think you got the answer then please close the thread accordingly and if not please let me know if you have any question.