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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
Pete230
Helper III
Helper III

Compare Date Column with current date

Hi guys,

 

I'm struggeling with the following: I would like to compare a date colum (last day of month) with the current month, if the current month is less or equal as the date colum then the numbers of the next column should be displayed, otherwise there should be a 0.

So I would like to see all the numbers until mai and for the following months just a 0.

 

Pete230_0-1685004618881.png

I guess it's not to hard, but I can not figure it out right now, any ideas will be appreciated.

 

Thank you and regards

Pete

1 ACCEPTED SOLUTION
JavidM
New Member

Alternatively, you can use the following M code without converting the Date column into datetime format:

= Table.AddColumn(#"Changed Type", "Custom", each if [Date] > DateTime.Date(Date.EndOfMonth(DateTime.LocalNow())) then 0 else [Amount])

 

Hope this helps!

View solution in original post

5 REPLIES 5
JavidM
New Member

Alternatively, you can use the following M code without converting the Date column into datetime format:

= Table.AddColumn(#"Changed Type", "Custom", each if [Date] > DateTime.Date(Date.EndOfMonth(DateTime.LocalNow())) then 0 else [Amount])

 

Hope this helps!

Works perfectly fine, thanks a lot!

Cheers
Pete

JavidM
New Member

You can use the following M code:

= Table.AddColumn(#"Changed Type1", "Custom", each if [Date] > Date.EndOfMonth(DateTime.LocalNow()) then 0 else [Amount])

Bear in mind that you have to convert the date column to datetime format before applying the function.

Pete230
Helper III
Helper III

Thank you for your answer. I would like to create the same in M (Power Querry) not in DAX, I wasnt pricise on that. Do you know that as well?

 

Thank you!

JavidM
New Member

Hi there,

 

If I understood your question correctly, you want to show the amounts up until the current month (May 2023) leaving zeros for all consecutive months. So, when we are in June 2023, the data will appear for the respective month only leaving July and future months as 0.

 

You can try using the following DAX function:

New Column =
IF('Table'[Date].[Date] > EOMONTH(TODAY(), 0), 0, 'Table'[Amount])
 
Let me know if it worked! Thanks!

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors