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
android1
Post Patron
Post Patron

Number of days between Earliest & Latest Dates

Hi,

 

I have a date column which I've added to a table. I want to see the earliest & latest dates do I've added this column twice.

How do I find the number of days between the earliest & latest dates. See pic.

 

Thanks,

android1Dates.jpg

 

 

 

 

 

2 ACCEPTED SOLUTIONS
gooranga1
Power Participant
Power Participant

hi @android1

 

I would create 2 measures to calculate the Start and End Date

 

Maximum Date = calculate(max([A/ Leave Date]))

Minimum Date = calculate(min([A/ Leave Date]))

 

Then a 3rd measure

 

difference = datediff([Minimum Date],[Maximum Date],DAY)

 

if your table has multiple rows for employee absence/attendance this method will only take the first and last date for that and calculate the days in between,

View solution in original post

difference = IF([Minimum Date] = [Maximum Date],1,datediff([Minimum Date],[Maximum Date],DAY))

@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

4 REPLIES 4
gooranga1
Power Participant
Power Participant

hi @android1

 

I would create 2 measures to calculate the Start and End Date

 

Maximum Date = calculate(max([A/ Leave Date]))

Minimum Date = calculate(min([A/ Leave Date]))

 

Then a 3rd measure

 

difference = datediff([Minimum Date],[Maximum Date],DAY)

 

if your table has multiple rows for employee absence/attendance this method will only take the first and last date for that and calculate the days in between,

Yeah, that works real good. Thanks.

 

One problem tho. If my min date is the same as my max date I want the difference to be 1 day.

So if min is 29/01/18 & max is 29/01/18 then difference needs to be 1 day.

difference = IF([Minimum Date] = [Maximum Date],1,datediff([Minimum Date],[Maximum Date],DAY))

@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Thats brilliant. Thanks very much.

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.