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

View all the Fabric Data Days sessions on demand. View schedule

Reply
Anonymous
Not applicable

Nb days between 2 dates

Hi everybody,

I did not find the issue, sorry il it exists.

I got a problem to find the delay between 2 dates with one id.

Ex :

id         date

1          01/05/2017

2          02/05/2017

3          02/05/2017

2          04/05/2017

3          05/05/2017

 

I would like "null" and 2 days for n°2 and "null" and 3 days for n°3 (and null for n°1)

I would like to have the average too, so 1 days for n°2 and 1,5 for n°3 (and 0 for n°1)

 

Am i clear or not?

Thank you for all,

Ben

1 ACCEPTED SOLUTION

Hi @Anonymous,

I reproduce your scenario and get expected results.

Please create the calculated coulmn using the formula below step by step.

Rank = RANKX(FILTER(Test,Test[id]=EARLIER(Test[id])),Test[date],,ASC)

Result = IF(ISBLANK(LOOKUPVALUE(Test[date],Test[id],Test[id],Test[Rank],Test[Rank]-1)),BLANK(),DATEDIFF(LOOKUPVALUE(Test[date],Test[id],Test[id],Test[Rank],Test[Rank]-1),Test[date],DAY))

Time = Test[Result]/Test[tx]


Desired resultDesired result
Best Regards,
Angelia

View solution in original post

5 REPLIES 5
Anonymous
Not applicable

Something more,

 

See what I would like :

 

id         date               result

1          01/05/2017    null

2          02/05/2017    null

3          02/05/2017    null

2          04/05/2017    2

3          05/05/2017    3

...

@Anonymous

 

ben what are you trying to do, probably easier if you explain the business requirement, ie whats your objective





If I took the time to answer your question and I came up with a solution, please mark my post as a solution and /or give kudos freely for the effort 🙂 Thank you!

Proud to be a Super User!




Anonymous
Not applicable

Ok, I try to explain the purpose...

 

with "tx" a percent (0,25 -> a garbage/container 25% fulfilled, need to be dumped),

the date is the date we dump the garbage/container,

the id is the reference of the container.

 

id         tx       date               result      Time

1          0,25    01/05/2017    null        /

2          0,5      02/05/2017    null        /

3          0,25    02/05/2017    null        /

2          1         04/05/2017    2           2

3          0,5      05/05/2017    3           6

...

 

The "Time" is the difference between the two last dates of the id divided by the tx.

It will be better with many "Time" to have one average time with each id.

 

 

Hi @Anonymous,

I reproduce your scenario and get expected results.

Please create the calculated coulmn using the formula below step by step.

Rank = RANKX(FILTER(Test,Test[id]=EARLIER(Test[id])),Test[date],,ASC)

Result = IF(ISBLANK(LOOKUPVALUE(Test[date],Test[id],Test[id],Test[Rank],Test[Rank]-1)),BLANK(),DATEDIFF(LOOKUPVALUE(Test[date],Test[id],Test[id],Test[Rank],Test[Rank]-1),Test[date],DAY))

Time = Test[Result]/Test[tx]


Desired resultDesired result
Best Regards,
Angelia

Anonymous
Not applicable

OMG!!

Successfull!!!

 

Thanks a lot!!

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

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!

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