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
CloudMonkey
Post Prodigy
Post Prodigy

date format doesn't work in if function

Hi,

 

I've tried the following if statement in a calculated measure:

TestDate = if(1=1,now(),0)

 

But instead of a date I am getting this output when I put the measure into a Card:

42K

 

I've tried changing the format to "Date" but that option is ghosted out. Please do you know how to fix?

 

Thanks,

 

CM

1 ACCEPTED SOLUTION

Because the value-if-false is not a date. If you replace that with a date value, then you'll be fine.

 

Example: TestDate = if(1=1,now(),DATE(2017,1,1))

Specializing in Power Query Formula Language (M)

View solution in original post

3 REPLIES 3
CloudMonkey
Post Prodigy
Post Prodigy

the full output with 15 decimal places is:

42.833606497689999 K

 

so I think this is a datetimestmp (with 42833 being the 8th April 2017). And the remaining decimal places being the time. But why does Power BI refuse to display this as a date/time?

Because the value-if-false is not a date. If you replace that with a date value, then you'll be fine.

 

Example: TestDate = if(1=1,now(),DATE(2017,1,1))

Specializing in Power Query Formula Language (M)

Thank you Marcel 🙂

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.