Forum Discussion
uhassan
2 years agoFrequent Visitor
Unable to get the time difference
I have account column in Power BI and against each accountant I have their login and logout time in one column, both are getting differentiated based on the status, I want to find how many hours a da...
- Anonymous2 years ago
Hi akhan786 ,
Modify formula like below:
Result = VAR curIndex = 'Data'[Index] VAR loggedOutTime = CALCULATE ( MAX ( 'Data'[EndTime] ), FILTER ( ALLEXCEPT ( 'Data', 'Data'[Account] ), 'Data'[Index] = curIndex - 1 && 'Data'[Login State] = "Logged Out" ) ) RETURN DATEDIFF ( loggedOutTime, IF ( ISBLANK ( loggedOutTime ), BLANK (), 'Data'[EndTime] ), MINUTE )Best Regards,
Adamk KongIf this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
2 years agoNot applicable
Hi uhassan ,
Try to create formula like below:
Result =
VAR curIndex = 'Table'[Index]
VAR loggedOutTime =
CALCULATE (
MAX ( 'Table'[EndTime] ),
FILTER (
ALLEXCEPT ( 'Table', 'Table'[Account] ),
'Table'[Index] = curIndex - 1
&& 'Table'[Login State] = "Logged Out"
)
)
RETURN
IF ( ISBLANK ( loggedOutTime ), BLANK (), MINUTE ( 'Table'[EndTime] ) )
- MINUTE ( loggedOutTime )
resul = MAXX('Table',[Result])
Best Regards,
Adamk Kong
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
uhassan
2 years agoFrequent Visitor
Hi Adamk Kong,
I have created the column from the dax which you have shared with me, but the output for some account is not correct, please find attached pbix file link where I have load the actual data.
https://drive.google.com/file/d/1DtGwN-SM0Ntux4pIrm8bURMclasUKGke/view?usp=sharing
Thanks