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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
ashely_nave
New Member

If statement with date

I have linked to our new maintenance system in PowerBi. I am trying to automate the machine downtime metric. In the calculation date field, I have an IF statement that says 

Calculation Date = if(isblank([Completed on]),[Current Date],[Completed on].[Date]). The point of this one is that to measure the downtime to date, I have to have an end. So if the work order in not completed, it returns the current date. This one works well.
I am new to PowerBi so I am stumbling through this. 

 I have a field [created.on]. I need a statement that says if [created.on] is before the current month, return the first date of the current month, if not return [created.on]. The reason for this is that downtime is measured by a monthly metric. So as the work order was started on 11/26, the downtime from 11/26-11/30 would be counted on the November downtime report. 

 

ashely_nave_0-1702331577791.png

 

Please let me know if anything is not clear. Any help would be greatly appreciated. 

 

1 ACCEPTED SOLUTION
vicky_
Super User
Super User

Please try the following formula:

Start Date = 
var startOfThisMonth = EOMONTH(TODAY(), -1) + 1
return IF('Table'[created_at] < startOfThisMonth, startOfThisMonth, 'Table'[created_at])

View solution in original post

2 REPLIES 2
ashely_nave
New Member

Thank you so much!

vicky_
Super User
Super User

Please try the following formula:

Start Date = 
var startOfThisMonth = EOMONTH(TODAY(), -1) + 1
return IF('Table'[created_at] < startOfThisMonth, startOfThisMonth, 'Table'[created_at])

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.