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
ERing
Helper V
Helper V

Need Help - New column with earliest date for each ID

I need to a way to create the Assigned Date column in Power Query. The goal of the coulmn is to assign the earlist Sale Date for each record with the same Territory_ID. One caveat is that the Assigned Date should be the Sale Date for any records where Territory_ID is null.

 

Can anyone help?

 

Capture 2.PNG

3 REPLIES 3
ERing
Helper V
Helper V

Also, I'm unable to save these changes as my table is using DirectQuery. Is there a way around this?

Vijay_A_Verma
Super User
Super User

Insert this step as next step where #"Changed Type" should be replaced with your previous step in both the places

= Table.AddColumn(#"Changed Type", "Custom", (x)=> if x[Territory_ID]=null then x[Sale Date] else List.Min(Table.SelectRows(#"Changed Type"[[Territory_ID],[Sale Date]], each ([Territory_ID] = x[Territory_ID]))[Sale Date]))

Thank you for this. Would it be possible to introdude Status as a criteria so that

 

if Status = New than Assigned Date = Sales Date

If Status = Existing than Assigned Date = EARLIEST Sale Date for records with same Territory_ID?

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.

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.