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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
Samcooke
Frequent Visitor

Need Help with Filtering to Max Date

Hi all, I am struggling with something that I thought would be easy but apparently not for me. I have a table of orders that have the product and the ship date for easch product. Some of the orders have multiple ship dates for the same Product Name. I am looking to filter to just display the latest (Max) Ship_Created_Date for each Product Name for each order. So in the below example it would only show the highlighted records for that particular order. Is there a DAX query, or some other solution, that can help with this?

 

Samcooke_1-1694545363543.png

 

 

1 ACCEPTED SOLUTION

Thanks for your feedback. I ended up using the below query I found somewhere else and replaced the table and fields with mine. It worked. I had never used "Filter" in a query before

MaxOfMonth = IF(
	Table1[date] = CALCULATE(
		MAX(TableName[date]),
		FILTER(
			ALL(TableName),
			MONTH(TableName[date]) = MONTH(EARLIER(TableName[date])) &&
			YEAR(TableName[date]) = YEAR(EARLIER(TableName[date]))
		)
	),
	TRUE,
	FALSE
)

 

View solution in original post

5 REPLIES 5
parry2k
Super User
Super User

@Samcooke ok, good luck but it is unnecessary, anyhow, you have the solution. Enjoy!



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Samcooke
Frequent Visitor

Thanks for your feedback. I ended up using the below query I found somewhere else and replaced the table and fields with mine. It worked. I had never used "Filter" in a query before

MaxOfMonth = IF(
	Table1[date] = CALCULATE(
		MAX(TableName[date]),
		FILTER(
			ALL(TableName),
			MONTH(TableName[date]) = MONTH(EARLIER(TableName[date])) &&
			YEAR(TableName[date]) = YEAR(EARLIER(TableName[date]))
		)
	),
	TRUE,
	FALSE
)

 

Ashish_Mathur
Super User
Super User

Hi,

Why have you n ot highlighted th e Product B row?  Also, do you want a measure or a Power Query solution?  Share data in a format that can be pasted in an MS Excel file.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
parry2k
Super User
Super User

@Samcooke why not add a measure for maximum ship date and then use that in the visual instead of ship_created_Date

 

Max Ship Date = MAX ( Table[Ship_Created_Date] )


Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Thanks for your feedback. I ended up using the below query I found somewhere else and replaced the table and fields with mine. It worked. I had never used "Filter" in a query before

MaxOfMonth = IF(
	Table1[date] = CALCULATE(
		MAX(TableName[date]),
		FILTER(
			ALL(TableName),
			MONTH(TableName[date]) = MONTH(EARLIER(TableName[date])) &&
			YEAR(TableName[date]) = YEAR(EARLIER(TableName[date]))
		)
	),
	TRUE,
	FALSE
)

 

Helpful resources

Announcements
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! Prices go up Feb. 11th.

Feb2025 Sticker Challenge

Join our Community Sticker Challenge 2025

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

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