Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Lenastray
Helper I
Helper I

calculate(meaure, date column = max(date column))

Hello everybody, please your assistance with this issue.

 

We have a table Table1 that has a date column and has a relationship with a date table. We have a measure Measure1 over Table1 that sums a column ColumnA like:

 

Measure1 := sum(Column1)

 

Now, if we fix Measure to give the calculation for a specific date like Calculate(Measure1, dateColumn = date(2020,11,27)) is all working perfect.

But if we do Calculate(Measure1, dateColumn = max(dateColumn)) its give error and if we use a variable like

var variable1 = max(dateColumn)
Calculate(Measure1, dateColumn = variable1) , it gives the measure for all dates, not for the max when is filtered for the date table.

 

We tried using filter, variables with same result. It’s some dax logic that we are overlooking?

 

Please, thanks to all in advance

 

 

2 ACCEPTED SOLUTIONS
amitchandak
Super User
Super User

@Lenastray , Try like

Calculate(Measure1, filter( Table, Table[dateColumn] = max(Table[dateColumn])))

View solution in original post

amitchandak
Super User
Super User

@Lenastray , Allexpcept or allselected need to used

 

Calculate([Measure1], filter( allselected(Table) , Table[dateColumn] = max(Table[dateColumn])))

 

or

 

Calculate([Measure1], filter( Table, Table[dateColumn] = max(Table[dateColumn])) , allexcept(Table, Table[COl1])

View solution in original post

4 REPLIES 4
Lenastray
Helper I
Helper I

Thanks a lot,  I use a minimum modification that resolve the issue

amitchandak
Super User
Super User

@Lenastray , Allexpcept or allselected need to used

 

Calculate([Measure1], filter( allselected(Table) , Table[dateColumn] = max(Table[dateColumn])))

 

or

 

Calculate([Measure1], filter( Table, Table[dateColumn] = max(Table[dateColumn])) , allexcept(Table, Table[COl1])

amitchandak
Super User
Super User

@Lenastray , Try like

Calculate(Measure1, filter( Table, Table[dateColumn] = max(Table[dateColumn])))

Ty amitchandak, but it returns the measure for all dates in date column. columnDate is a column from Table1 and its filtered by the date column of the date table. The problems I see is at the context transition. max() says give me the max over the current filter conext, but when is filtered by the date table, for max the max table is the current date for all the rows of the date column of the date table. 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors