cancel
Showing results for
Search instead for
Did you mean: Frequent Visitor

## How to determine the max date for a week across the year?

I have a table in which I have a date, the associated week and the associated year as three columns. I would like to determine the max date for each week and for each year using PowerBI. I tried the following code but I am getting the max date across entire column.

1 ACCEPTED SOLUTION  Super User III

Here is a simple version of a calculated column using CALCULATE

Max Date Week =
VAR Y= [Fiscal Year]
VAR W= [Fiscal Week]
RETURN CALCULATE(MAX('Table'[Date]),All('Table'),'Table'[Fiscal Year]=Y,'Table'[Fiscal Week]=W)

If you don't like variables:

Max Date Week = CALCULATE(MAX('Table'[Date]),REMOVEFILTERS('Table'[Date]))

If you want to be more sophisticated you can use MAXX:

return maxx(filter('Table','Table'[Fiscal Week]=W && 'Table'[Fiscal Year]=Y),'Table'[Date])

1 REPLY 1  Super User III

Here is a simple version of a calculated column using CALCULATE

Max Date Week =
VAR Y= [Fiscal Year]
VAR W= [Fiscal Week]
RETURN CALCULATE(MAX('Table'[Date]),All('Table'),'Table'[Fiscal Year]=Y,'Table'[Fiscal Week]=W)

If you don't like variables:

Max Date Week = CALCULATE(MAX('Table'[Date]),REMOVEFILTERS('Table'[Date]))

If you want to be more sophisticated you can use MAXX:

return maxx(filter('Table','Table'[Fiscal Week]=W && 'Table'[Fiscal Year]=Y),'Table'[Date])  ## Helpful resources

Announcements #### Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group #### The largest Power BI virtual conference

100+ sessions, 100+ speakers, Product managers, MVPs, and experts. All about Power BI. Attend online or watch the recordings. #### Experience what’s next for Power BI

See the latest Power BI innovations, updates, and demos from the Microsoft Business Applications Launch Event. Top Solution Authors
Top Kudoed Authors
Users online (16,814)