cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
sam49
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.

 

Capture_PowerBI.PNG

I tried the following code but I am getting the max date across entire column.

1 ACCEPTED SOLUTION
lbendlin
Super User III
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])

View solution in original post

1 REPLY 1
lbendlin
Super User III
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])

View solution in original post

Helpful resources

Announcements
PBI User Groups

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

March Update

Check it Out!

Click here to read more about the March 2021 Updates!

secondImage

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.

secondImage

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