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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Anonymous
Not applicable

Power Query Editor: Calcualte Date difference (some columns blank)

Hi,

 

How would in DAX calculate the number of days between 2 date columns

  • Column1 (format: date): 17-11-2016
  • Column2 (format: date): 19-11-2016

Wanted outcome (format: whole number): 2

 

Note: some Colum2 will be blank - here I would like a blank cell as outcome as well

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi,


It seems this will work:

 

= IFERROR
(DATEDIFF(
table[column1],
table[column2],
DAY),
BLANK())

View solution in original post

5 REPLIES 5
amitchandak
Super User
Super User

@Anonymous ,

 

Power Query

Duration.Days(Duration.From([Column2]-[Column1])))

 

In DAX

Try new column

Datediff([column1],[column2],day)

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

Wont work,

I alsso tried:

 

DATEDIFF
MIN( table[column1]),
MAX( table[column2]),
DAY)

@Anonymous , That is the measure .Hope your date setting is correct

https://community.powerbi.com/t5/Desktop/How-to-apply-UK-date-format-dd-mm-yyyy-in-Date-slicer/td-p/599712

 

 

Can you share a sample pbix after removing sensitive data.

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

Hi,

 

It seems the your link is about the date format and a slicer,

 

What i need is the date difference in days from 2 columns already formatted as date - as a DAX formula,

Anonymous
Not applicable

Hi,


It seems this will work:

 

= IFERROR
(DATEDIFF(
table[column1],
table[column2],
DAY),
BLANK())

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 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