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

A new Data Days event is coming soon! This time we’re going bigger than ever. Fabric, Power BI, SQL, AI and more. Don't miss out.

Reply
Anonymous
Not applicable

Create a custom column with a new date based off another's column date

Hello,

 

I'm new to powerBI so I think this should be easy.

I want to create a custom column based off another column's date. If the original column is before today I want the custom column to show todays' date

If the date is after today then I want to show the original date.

 

If this was in excel the formula would be this: =IF(A2<TODAY(),TODAY(),A2)

 

Is there an easy way to do this?

1 ACCEPTED SOLUTION
Icey
Community Support
Community Support

Hi @Anonymous ,

 

Power Query Editor is used to connect to one or many data sources, to shape and transform the data to meet your needs. Then you can load that model into Power BI Desktop to create reports.

For Power Query Editor, you can refer to this document: https://docs.microsoft.com/en-us/power-bi/desktop-query-overview.

For Power BI Desktop, you can refer to this document: https://docs.microsoft.com/en-us/power-bi/desktop-what-is-desktop.

 

Then, let's answer your question.

 

If you want to create a custom column in Power Query Editor, you can try this:

1. Add Column -> Custom Column.

powerquery2.PNG

 

 

2. Type the M expression:

= if [Date] < Date.From(DateTime.LocalNow()) then Date.From(DateTime.LocalNow()) else [Date]

powerquery3.PNG

 

3. Then you can get a custom column that meets your requirements.

powerquery.PNG

 

If you want to create a Calculated Column in Power BI Desktop. Try this:

1. Modeling -> New Column.

2. Type the DAX expression:

Column = IF([Date]<TODAY(),TODAY(),[Date])

pbid.gif

 

For details, please check the attached PBIX file.

 

 

Best Regards,

Icey

 

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
Greg_Deckler
Community Champion
Community Champion

In DAX it is very similar:

 

Column = IF([Date]<TODAY(),TODAY(),[Date])


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...
Anonymous
Not applicable

Thanks...I'm very new to PowerBI so I think I'm trying to enter the formula in the wrong spot.

 

I went to Power Query  Editor and clicked on Custom Column. I followed the wizard and typed in the synatex like this:

=IF(Loading Date]<TODAY(),TODAY(),[Loading Date])

 

This then became the below:

= Table.AddColumn(#"Changed Type2", "Custom", each IF([Loading Date]<TODAY(),TODAY(),[Loading Date]))

and I got this error: Expression.Error: The name 'IF" wasn't recognized. Make sure it's spelled correctly.

 

I must be doing something very simple that isn't right.

Icey
Community Support
Community Support

Hi @Anonymous ,

 

Power Query Editor is used to connect to one or many data sources, to shape and transform the data to meet your needs. Then you can load that model into Power BI Desktop to create reports.

For Power Query Editor, you can refer to this document: https://docs.microsoft.com/en-us/power-bi/desktop-query-overview.

For Power BI Desktop, you can refer to this document: https://docs.microsoft.com/en-us/power-bi/desktop-what-is-desktop.

 

Then, let's answer your question.

 

If you want to create a custom column in Power Query Editor, you can try this:

1. Add Column -> Custom Column.

powerquery2.PNG

 

 

2. Type the M expression:

= if [Date] < Date.From(DateTime.LocalNow()) then Date.From(DateTime.LocalNow()) else [Date]

powerquery3.PNG

 

3. Then you can get a custom column that meets your requirements.

powerquery.PNG

 

If you want to create a Calculated Column in Power BI Desktop. Try this:

1. Modeling -> New Column.

2. Type the DAX expression:

Column = IF([Date]<TODAY(),TODAY(),[Date])

pbid.gif

 

For details, please check the attached PBIX file.

 

 

Best Regards,

Icey

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
May Power BI Update Carousel

Power BI Monthly Update - May 2026

Check out the May 2026 Power BI update to learn about new features.

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.