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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
Anonymous
Not applicable

Create if then clause with greater than or less than comparing dates

I have two columns with dates that I would like to compare and create a new custom column in Power Query.

 

What I want do do is is determine if the [Date] is <= to [Date End of Month]. If it's <= then I want to display "Less than current month" if it's > then I want to display "Greater than current month"

 

How do I create this custom column?

 

if then.png

1 ACCEPTED SOLUTION
edhans
Super User
Super User

Hi @Anonymous Try this formula. It returns this, today being July 28, 2020.

edhans_0-1595949050091.png

=if [Date] >= Date.EndOfMonth(DateTime.Date(DateTime.LocalNow())) then "Greater than Current Month" else "Less than Current Month"

 



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting

View solution in original post

3 REPLIES 3
edhans
Super User
Super User

Hi @Anonymous Try this formula. It returns this, today being July 28, 2020.

edhans_0-1595949050091.png

=if [Date] >= Date.EndOfMonth(DateTime.Date(DateTime.LocalNow())) then "Greater than Current Month" else "Less than Current Month"

 



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting
Anonymous
Not applicable

 

here you can find the functions that could help you to get the result

 

https://docs.microsoft.com/it-it/powerquery-m/date-isincurrentmonth

 

 

Anonymous
Not applicable

Thank you, I actually used those formulas to create some other columns...but I'm not clear how to create an if then clause using >= to compare columns. Any ideas how to an if then comparing columns?

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!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.