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
Anonymous
Not applicable

Calculated Column for Date Codes with Blanks

I have two date columns that I am attempting to find the difference between. The issue is that about 1/3rd are missing at least one date. Would like the calculated column to zero out the whole formula instead of subtracting from 01/01/1900 the way it currently is.

 

What I get:

Start Date 1   Start  Date 2   Difference Between
05/02/2025   05/17/2025   15
04/28/2025    -4689
    05/22/2025   4698

 

What I want:

Start Date 1   Start  Date 2   Difference Between
05/02/2025   05/17/2025   15
04/28/2025    0
    05/22/2025   0

Any suggestions on how to do this with Calculated Columns?

 

1 ACCEPTED SOLUTION
uzuntasgokberk
Super User
Super User

Hello @Anonymous ,

You can change the measure like this:
"
measure =
IF( ISBLANK([start_date2]) || ISBLANK([start_date1]), 0, [start_date1] -[start_date2])
"

Kind Regards,
Gökberk Uzuntaş

📌 If this post helps, then please consider Accepting it as a solution and giving Kudos — it helps other members find answers faster!

🔗 Stay Connected:
📘 Medium |
📺 YouTube |
💼 LinkedIn |
📷 Instagram |
🐦 X |
👽 Reddit |
🌐 Website |
🎵 TikTok |

View solution in original post

3 REPLIES 3
uzuntasgokberk
Super User
Super User

Hello @Anonymous ,

You can change the measure like this:
"
measure =
IF( ISBLANK([start_date2]) || ISBLANK([start_date1]), 0, [start_date1] -[start_date2])
"

Kind Regards,
Gökberk Uzuntaş

📌 If this post helps, then please consider Accepting it as a solution and giving Kudos — it helps other members find answers faster!

🔗 Stay Connected:
📘 Medium |
📺 YouTube |
💼 LinkedIn |
📷 Instagram |
🐦 X |
👽 Reddit |
🌐 Website |
🎵 TikTok |

Anonymous
Not applicable

Perfect. Thank you very much.

rajendraongole1
Super User
Super User

Hi @Anonymous  - Yes, you can create a calculated column in Power BI using DAX that returns 0 if either of the two dates is missing, and otherwise returns the correct date difference.

 

rajendraongole1_0-1748456674462.png

 

Hope this helps. 

 

Please find the attached pbix file FYR.





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





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.