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
Crydus
Helper I
Helper I

Need Help with MAX Date with multiple conditions

Hello,

I need some help regarding a calculated column which returns me the MAX(X) date with a second set of filters. I have basic knowledge on how to use the MAXX()-Expression for that, but I don't know how and if I can add another filter to this expression. 

Our company has a list of prices (item_customer_relationship) with valid_from and valid_to dates, with the limitation that valid_to is not really in use anymore (I will provide an example belw with the basic idea of this table.) My problem now is that I have to identify the current price which is valid. 
I now need a calculated column which returns the values found in remark. The only thing I manage to get is the max valid_from Date per Item but I do not now how to include the valid_to date. 


Currently our system basically has 3 options: 
Item0001 is the best case, with all dates filled, Item0002 is the case where valid_to is implemented for the next price change, but currently it is not in use, Item0003 is the case where No valid_to date is provided. 

 

Item KeyValid FromValid ToRemark
Item000101.04.202401.04.2025Valid in Future
Item000101.04.202301.04.2024Valid
Item000101.04.202201.04.2023Not Valid
Item000201.04.202401.04.2025Valid in Future
Item000201.04.2023 Valid
Item000201.04.2022 Not Valid
Item000301.04.2024 Valid in Future
Item000301.04.2023 Valid
Item000301.04.2022 Not Valid


I hope that you can help me. Please feel free to ask for more information, I will provide as much as I can if anything is needed. 

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@Crydus , A new column in a sales/transaction table

Price from item to sales =

Maxx(filter(Item , Item[Item Key] = sales[Item Key] && Sales[Date]>= Item[Valid From] && Sales[Date]<= Item[Valid To]) , Item[Price]) 

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

View solution in original post

1 REPLY 1
amitchandak
Super User
Super User

@Crydus , A new column in a sales/transaction table

Price from item to sales =

Maxx(filter(Item , Item[Item Key] = sales[Item Key] && Sales[Date]>= Item[Valid From] && Sales[Date]<= Item[Valid To]) , Item[Price]) 

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

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!

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.