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
Anonymous
Not applicable

Check for earliest date in table for comparison using M results in cyclic error

In Power Query, I have a table which has a date column. I want to write a custom column that checks if the date is the minimum date for that field, then return true, else false.

 

if List.Contains({List.Min(#"Table"[Date])},[Date]) then true else false

 

Do I need to have a separate object for comparison? I would never use this minimum date in another location, and if possible would like to avoid creating a referenced table or something similar.

1 ACCEPTED SOLUTION
v-yulgu-msft
Employee
Employee

Hi @Anonymous,

 

To get the minimum date in a column, please refer to this syntax:

AddCustom = Table.AddColumn(PreviousStep, "Custom", each List.Max(PreviousStep[a]))

 

Then, wrap above step inside an if condition.

= Table.AddColumn(#"Changed Type", "Custom.1", each if [Date]=List.Min(#"Changed Type"[Date]) then "true" else "false")

1.PNG

 

Best regards,

Yuliana Gu

 

Community Support Team _ Yuliana Gu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
v-yulgu-msft
Employee
Employee

Hi @Anonymous,

 

To get the minimum date in a column, please refer to this syntax:

AddCustom = Table.AddColumn(PreviousStep, "Custom", each List.Max(PreviousStep[a]))

 

Then, wrap above step inside an if condition.

= Table.AddColumn(#"Changed Type", "Custom.1", each if [Date]=List.Min(#"Changed Type"[Date]) then "true" else "false")

1.PNG

 

Best regards,

Yuliana Gu

 

Community Support Team _ Yuliana Gu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hello @v-yulgu-msft,

 

what condition would I need to add in order to get the minimun date for each site?

 

Best Regards

Anonymous
Not applicable

@ratercero I ended up just bringing in a second reference to the table for another situation, grouping on the ID and value, then merging it in to make it work. I found that even if I could make more of it work in a single step that it ended up hurting readability for anyone else coming in after me.

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.