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

Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!

Reply
Nobody1292
Regular Visitor

Date difference blank

Hi,

I would like to calculate the number of days between two dates in a column.
I have now solved this:

= Duration.Days([M2.A Forecast Date] - [M1 Forecast Date])

 

But how can I add that this is only calculated if none of the dates is empty? Then I would also like an empty cell.

Can someone maybe help me with this?
Thanks a lot!
Nobody

1 ACCEPTED SOLUTION
themistoklis
Community Champion
Community Champion

 

Try the following formula as you are using Power Query:

 

if [M2.A Forecast Date] = null or [M1 Forecast Date] = null then null else Duration.Days([M2.A Forecast Date] - [M1 Forecast Date])

 

View solution in original post

4 REPLIES 4
speedramps
Super User
Super User

Hi Nobody

 

We want to help you but it looks like you asked this question in a rush.

It does not make sense. "how can I add that this is only calculated if none of the dates is empty" ☹️

Please take time to write questions clearly and you will get quicker answers. Thanks 😀

Anonymous
Not applicable

HI

 

Pleasr try :

if(or(ISBLANK(SELECTEDVALUE([M2.A Forecast Date])),ISBLANK(SELECTEDVALUE([M1 Forecast Date]))),,Duration.Days([M2.A Forecast Date] - [M1 Forecast Date]))
themistoklis
Community Champion
Community Champion

 

Try the following formula as you are using Power Query:

 

if [M2.A Forecast Date] = null or [M1 Forecast Date] = null then null else Duration.Days([M2.A Forecast Date] - [M1 Forecast Date])

 

thank you, it works 🙂

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

Vote for your favorite vizzies from the Power BI World Championship submissions!

Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 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.