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
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))


Follow on LinkedIn
@ 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!:
DAX For Humans

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))


Follow on LinkedIn
@ 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!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Thats brilliant. Thanks very much.

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.