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
Samhunt
Helper I
Helper I

Date smaller than first day of current month

Hello Everyone, 

 

I am new to this so I require some help. 

 

Because I add my data on the first days of next month I want to create a column Query that will mark all dates that are smaller than the first day of the current month to be marked as past and all the dates in the current month and onward to be marked as future

 

So this is what I tried which is wrong as I received an error in my column

 

=if [date] < Date.StartOfMonth(DateTime.LocalNow()) then "Past" else "Future"

 

So for example now we have February, I want in the new column all dates before the 01/02/2024 to be marked as past

 

Thanks for your time

1 ACCEPTED SOLUTION
dufoq3
Super User
Super User

The issue is with  DateTime.LocalNow(), because it is as datetime - just add Date.From before it.

 

 

if Date.From([date]) < Date.StartOfMonth(Date.From(DateTime.LocalNow())) then "Past" else "Future"

 

 

 


Note: Check this link to learn how to use my query.
Check this link if you don't know how to provide sample data.

View solution in original post

2 REPLIES 2
dufoq3
Super User
Super User

The issue is with  DateTime.LocalNow(), because it is as datetime - just add Date.From before it.

 

 

if Date.From([date]) < Date.StartOfMonth(Date.From(DateTime.LocalNow())) then "Past" else "Future"

 

 

 


Note: Check this link to learn how to use my query.
Check this link if you don't know how to provide sample data.

Hi @dufoq3 


Works as a charm thank you very much really appreciated

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.

Top Solution Authors
Top Kudoed Authors