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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
MathieuF
Helper III
Helper III

Find a value / LOOKUPVALUE

Good morning all,
Not finding a solution to my problem, I try to work around the thing.

https://community.powerbi.com/t5/DAX-Commands-and-Tips/Calculation-between-2-dates-based-on-the-same...


I want to display on the same line the start date (task.taken) and the end date (task.completed) of the same "task_id".
I illustrated this.

 

CapturePBI.PNG


I carried out tests with in particular the LOOKUPVALUE formula that you can find in .testrecherche and .testrecherche2.

the difficulty I encounter is that the value "task-id" or the one found in "task_id_debut / fin" can be repeated. I need to have the one that comes right after (chronological order of created_at).

Thanks for your help.

 

Mathieu

 

PBIX: https://www.dropbox.com/sh/61ae2dtbmobl8tp/AAATpy0sRBMGRziU0Xe7Sy_Za?dl=0

7 REPLIES 7
MathieuF
Helper III
Helper III

Hello,
I'm sorry, my problem is still there.
How to make it take into account the next non empty line?
Should I use the ALLNOBLANK function? And how ?
Thanks in advance.

@Greg_Deckler 

Greg_Deckler
Community Champion
Community Champion

@MathieuF See my article on Mean Time Between Failure (MTBF) which uses EARLIER: http://community.powerbi.com/t5/Community-Blog/Mean-Time-Between-Failure-MTBF-and-Power-BI/ba-p/3395....
The basic pattern is:
Column = 
  VAR __Current = [Value]
  VAR __PreviousDate = MAXX(FILTER('Table','Table'[Date] < EARLIER('Table'[Date])),[Date])

  VAR __Previous = MAXX(FILTER('Table',[Date]=__PreviousDate),[Value])
RETURN
  __Current - __Previous

 

You may need to use MINX in your example.



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

@Greg_Deckler

I had seen your article and wanted to adapt it without success.
I tested your formula, but it didn't give the same result (I removed the subtraction to test.

CapturePBI.PNG


.testRecherche3 =
VAR __Current = journal_forum[created_at]
VAR __PreviousDate = MINX(FILTER(journal_forum;journal_forum[created_at] < EARLIER(journal_forum[created_at]));journal_forum[created_at])

VAR __Previous = MINX(FILTER(journal_forum;journal_forum[created_at]=__PreviousDate);journal_forum[created_at])
RETURN
//__Current -
- __Previous

 

 

I tried this formula, but it only works for the first part. Not the second.
.testRecherche2 = IF(ISBLANK(journal_forum[Task_id_debut])=BLANK();CALCULATE(MIN(journal_forum[created_at]);FILTER(ALL(journal_forum);journal_forum[Task_id_fin]=EARLIER(journal_forum[Task_id_debut])));BLANK())

 

CapturePBI.PNG

 

Mathieu

 

@MathieuF - 

I tried this formula, but it only works for the first part. Not the second.
.testRecherche2 = IF(ISBLANK(journal_forum[Task_id_debut])=BLANK();CALCULATE(MIN(journal_forum[created_at]);FILTER(ALL(journal_forum);journal_forum[Task_id_fin]=EARLIER(journal_forum[Task_id_debut])));BLANK())

 

You would need to include an additional filter like:

IF(ISBLANK(journal_forum[Task_id_debut])=BLANK();CALCULATE(MIN(journal_forum[created_at]);FILTER(ALL(journal_forum);journal_forum[Task_id_fin]=EARLIER(journal_forum[Task_id_debut]) && journal_forum[created_at]>EARLIER(journal_forum[created_at])));BLANK())


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

Helolo @Greg_Deckler 

Thank you very much, thanks to you, I am reaching my goal.

There is one small problem.
Indeed, if I take the example of user_id 5be2f44514bf8a39cb988ff5 and task_id 5fcdf9e9bd0e542b263be8a8 (same with 5fcbc85e71336801d1debc25) we can see that there are interactions between (content.replied) which give empty fields. So I think EARLIER does not detect the next value.

 

CapturePBI2.PNG


How to cure it ?

My files: https://www.dropbox.com/sh/61ae2dtbmobl8tp/AAATpy0sRBMGRziU0Xe7Sy_Za?dl=0


Columns concerned:
task_id_debut
task_id_fin
.testrecherche2
.created_at_debut
.Measure1 / .testrecherche4

 

Moreover, there are surely simpler, without using so many columns.


Thank you for your precious help.

 

Mathieu

Greg_Deckler
Community Champion
Community Champion

@MathieuF - So what is the expected output then?



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

Hello @Greg_Deckler and thank you for looking into my case.
I want to calculate the time between the start of the action and the end of the action.
Here is the result that I hope (before proceeding with the subtraction).

 

CapturePBI.PNG

 

Mathieu

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 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.