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
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! 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.