cancel
Showing results for
Did you mean:
Helper V

## 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

1 ACCEPTED SOLUTION
Community Champion

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/

Thank you for the kudos 🙂

Proud to be a Super User!

2 REPLIES 2
Resident Rockstar

Hi @jatneerjat,

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

Community Support Team _ Cherry Gao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Community Champion

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/

Thank you for the kudos 🙂

Proud to be a Super User!

Announcements

#### 2023 Release Wave 1 Plans

Power BI release plans for 2023 release wave 1 describes all new features releasing from April 2023 through September 2023.

#### Global Power BI Training

Make sure you register today for the Power BI Summit 2023. Don't miss all of the great sessions and speakers!

#### Business Application LATAM Summit 2023

Join the biggest FREE Business Applications Event in LATAM this February.

#### Global Power Platform Bootcamp

In this bootcamp we will deep-dive into Microsoft’s Power Platform stack with hands-on sessions and labs, delivered to you by experts and community leaders.

Top Solution Authors
Top Kudoed Authors