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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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)

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.

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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.