Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more.
Get startedGrow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.
Hello.
I'm trying to do a time duration here based on a lookup.
I want to find duration that Column A > x to value Column A NOT > x.
For example:
Column A > x at 12/12/21 09:00.
Column A became NOT > x at 12/12/21 09:43
Duration would be the difference. I know this is a dumb question but I assume the lookup or Select moves forward in time? Never backwards?
I would expect a result of list of duration values.
Thanks for any help.
Solved! Go to Solution.
Hi, @hxnwx ,
You could create a measure as follow:
Measure =
var _next=CALCULATE(MAX('Table'[DATE/TIME]),FILTER(ALL('Table'),[A]=MAX([A])&&[Status]="No"))
var _dura= DATEDIFF(MAX('Table'[DATE/TIME]), _next,SECOND)
return RIGHT ( "0" & INT ( _dura / 3600 ), 2 )
& ":"
& RIGHT (
"0"
& INT ( ( _dura - INT (_dura / 3600 ) * 3600 ) / 60 ),
2
)
& ":"
& RIGHT ( "0" & MOD (_dura, 60 ), 2 )
The final show:
If the above one can't help you get the desired result, please provide some sample data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It is better if you can share a simplified pbix file. You can refer the following link to upload the file to the community. Thank you.
How to upload PBI in Community
Best Regards,
Community Support Team _ Yalan Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi, @hxnwx
Try it.
Measure =
var _pre=CALCULATE(MIN('Table'[DATE/TIME]),FILTER(ALL('Table'),[DATE/TIME]<MAX('Table'[DATE/TIME])&&[lo_ifr_ind]=1))
var _dur= DATEDIFF(_pre,MAX('Table'[DATE/TIME]),SECOND)
var _dura=IF(MAX('Table'[lo_ifr_ind])= CALCULATE(MAX('Table'[lo_ifr_ind]),FILTER(ALL('Table'),[DATE/TIME]= CALCULATE(MAX('Table'[DATE/TIME]),FILTER(ALL('Table'),[DATE/TIME]<MAX('Table'[DATE/TIME]))))),"00:00:00",_dur)
return
RIGHT ( "0" & INT ( _dura / 3600 ), 2 )
& ":"
& RIGHT (
"0"
& INT ( ( _dura - INT (_dura / 3600 ) * 3600 ) / 60 ),
2
)
& ":"
& RIGHT ( "0" & MOD (_dura, 60 ), 2 )
The final show:
Best Regards,
Community Support Team _ Yalan Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi, @hxnwx
Try it.
Measure =
var _pre=CALCULATE(MIN('Table'[DATE/TIME]),FILTER(ALL('Table'),[DATE/TIME]<MAX('Table'[DATE/TIME])&&[lo_ifr_ind]=1))
var _dur= DATEDIFF(_pre,MAX('Table'[DATE/TIME]),SECOND)
var _dura=IF(MAX('Table'[lo_ifr_ind])= CALCULATE(MAX('Table'[lo_ifr_ind]),FILTER(ALL('Table'),[DATE/TIME]= CALCULATE(MAX('Table'[DATE/TIME]),FILTER(ALL('Table'),[DATE/TIME]<MAX('Table'[DATE/TIME]))))),"00:00:00",_dur)
return
RIGHT ( "0" & INT ( _dura / 3600 ), 2 )
& ":"
& RIGHT (
"0"
& INT ( ( _dura - INT (_dura / 3600 ) * 3600 ) / 60 ),
2
)
& ":"
& RIGHT ( "0" & MOD (_dura, 60 ), 2 )
The final show:
Best Regards,
Community Support Team _ Yalan Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi Yalan Wu,
I think this is close though I might have the column names incorrect in Measure.
I get the following response. I can see the Duration column(Measure).
I would expect to see a value in this column on the 6/5/2022 1:42:00 PM row.
This is where column 'lo_ifr_ind' changed from 1 to 0. The duration it was = 1, should be from:
6/5/2022 10:39:00 AM (changed from 0 to 1)
6/5/2022 1:42:00 PM (changed from 1 back to 0)
So duration would be close to 03:03:00.
Here is what I have for the Measure:
Duration = var _next=CALCULATE(MAX('Query1'[wthr_prd_iss_gts]),FILTER(ALL('Query1'),[wthr_prd_iss_gts]=MAX([wthr_prd_iss_gts])&&[lo_ifr_ind]=0)) var _dura= DATEDIFF(MAX('Query1'[wthr_prd_iss_gts]), _next,SECOND) return RIGHT ( "0" & INT ( _dura / 3600 ), 2 ) & ":" & RIGHT ( "0" & INT ( ( _dura - INT (_dura / 3600 ) * 3600 ) / 60 ), 2 ) & ":" & RIGHT ( "0" & MOD (_dura, 60 ), 2 )
Hi, @hxnwx ,
You could create a measure as follow:
Measure =
var _next=CALCULATE(MAX('Table'[DATE/TIME]),FILTER(ALL('Table'),[A]=MAX([A])&&[Status]="No"))
var _dura= DATEDIFF(MAX('Table'[DATE/TIME]), _next,SECOND)
return RIGHT ( "0" & INT ( _dura / 3600 ), 2 )
& ":"
& RIGHT (
"0"
& INT ( ( _dura - INT (_dura / 3600 ) * 3600 ) / 60 ),
2
)
& ":"
& RIGHT ( "0" & MOD (_dura, 60 ), 2 )
The final show:
If the above one can't help you get the desired result, please provide some sample data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It is better if you can share a simplified pbix file. You can refer the following link to upload the file to the community. Thank you.
How to upload PBI in Community
Best Regards,
Community Support Team _ Yalan Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Thanks Yalan.
Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.
Ask questions in Eventhouse and KQL, Eventstream, and Reflex.
User | Count |
---|---|
85 | |
83 | |
66 | |
60 | |
57 |
User | Count |
---|---|
188 | |
111 | |
105 | |
78 | |
71 |