Reply
Member
Posts: 121
Registered: ‎05-29-2018
Accepted Solution

Max(Date) vs Lastdate(Date): which one should use for better performance

Hi,

 

As i am working on improving performance of measures, which function should i use to get the latest date from a date table?

 

Max(Date) or LastDate(Date)

 

Thanks


Accepted Solutions
Highlighted
Super Contributor
Posts: 743
Registered: ‎06-23-2016

Re: Max(Date) vs Lastdate(Date): which one should use for better performance

in this article there is a short paragraph about the 2
https://www.sqlbi.com/articles/semi-additive-measures-in-dax/


basically LASTDATE returns a table of one column and one row, while MAX returns scalar value
accoriding to the article this code is equivalent to LASTDATE

        FILTER (
            ALL( 'Date'[Date] ), 
            'Date'[Date] = MAX ( 'Date'[Date] )
        )

so to answer your question if you need a scalar I'd use MAX

on optimization in general - I recommend watching this video and in avoiding iterator functions on full tables if possible
https://www.sqlbi.com/tv/optimizing-dax-queries/

View solution in original post


All Replies
Highlighted
Super Contributor
Posts: 743
Registered: ‎06-23-2016

Re: Max(Date) vs Lastdate(Date): which one should use for better performance

in this article there is a short paragraph about the 2
https://www.sqlbi.com/articles/semi-additive-measures-in-dax/


basically LASTDATE returns a table of one column and one row, while MAX returns scalar value
accoriding to the article this code is equivalent to LASTDATE

        FILTER (
            ALL( 'Date'[Date] ), 
            'Date'[Date] = MAX ( 'Date'[Date] )
        )

so to answer your question if you need a scalar I'd use MAX

on optimization in general - I recommend watching this video and in avoiding iterator functions on full tables if possible
https://www.sqlbi.com/tv/optimizing-dax-queries/

Community Support Team
Posts: 2,654
Registered: ‎02-06-2018

Re: Max(Date) vs Lastdate(Date): which one should use for better performance

Hi @jatneerjat,

 

Have you solved your problem?

 

If you have solved, please accept the replies making sense as solution to your question so that people who may have the same question can get the solution directly.

 

Best  Regards,

Cherry