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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
surajv3
New Member

Filter Report by Max Date

Hello, 

 

I am new to Power BI and would like help with this scenario I am not able to solve

 

The data that I have is as follows

 

IDTitleTeamApplicationChangedDate
1Data1T1 8/30/2016 9:13:30 AM
1Data1T1A18/30/2016 10:33:40 AM
1Data1T2A19/1/2016 7:53:30 PM
2Data2  8/30/2016 9:23:30 AM
2Data2T3A39/1/2016 2:53:30 PM

   

 

What I would like to display in the report is only these rows that corresponds to the Max Changed Date

 

IDTitleTeamApplicationChangedDate
1Data1T2A19/1/2016 7:53:30 PM
2Data2T3A39/1/2016 2:53:30 PM

 

Thanks for your help in advance,

 

1 ACCEPTED SOLUTION
KGrice
Memorable Member
Memorable Member

Hi @surajv3. One way you can do this is by going to the Data view and adding a new column that will indicate which row contains the max changed date by ID. Here's the column I used:

 

IsLatestChangedDateByID = TableName[ChangedDate] = 
CALCULATE(
MAX(TableName[ChangedDate]),
FILTER(ALL(TableName), TableName[ID]=EARLIER(TableName[ID]))
)

 

Using that will give you a True/False indicator that you can use in Filters, Slicers, etc.

 

LASTNONBLANK.PNG

 

Another way to get the same result is to use LASTNONBLANK instead of MAX:

 

IsLatestChangedDateByID = TableName[ChangedDate] = 
	CALCULATE(
		LASTNONBLANK(TableName[ChangedDate], 1), 
		FILTER(ALL(TableName), TableName[ID]=EARLIER(TableName[ID]))
	)

 

That's what I used at first, but then though the MAX solution is probably more intuitive. I only showed both so you know the options are there, and there are some cases where LASTNONBLANK will be more helpful than MAX.

View solution in original post

4 REPLIES 4
KGrice
Memorable Member
Memorable Member

Hi @surajv3. One way you can do this is by going to the Data view and adding a new column that will indicate which row contains the max changed date by ID. Here's the column I used:

 

IsLatestChangedDateByID = TableName[ChangedDate] = 
CALCULATE(
MAX(TableName[ChangedDate]),
FILTER(ALL(TableName), TableName[ID]=EARLIER(TableName[ID]))
)

 

Using that will give you a True/False indicator that you can use in Filters, Slicers, etc.

 

LASTNONBLANK.PNG

 

Another way to get the same result is to use LASTNONBLANK instead of MAX:

 

IsLatestChangedDateByID = TableName[ChangedDate] = 
	CALCULATE(
		LASTNONBLANK(TableName[ChangedDate], 1), 
		FILTER(ALL(TableName), TableName[ID]=EARLIER(TableName[ID]))
	)

 

That's what I used at first, but then though the MAX solution is probably more intuitive. I only showed both so you know the options are there, and there are some cases where LASTNONBLANK will be more helpful than MAX.

After several tries of finding the latest date grouped by customer, this was the one that worked. Thanks.

Hi, Thanks for your tip. However, this is not working for me. I am wondering if it is comparing row to row so it's returning 'true' for all rows. 

 

 

 

Thank you,

Inês Castelhano

Thank you so much for your help, Used the formula with MAX 

 

Thanks again

 

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

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

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

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