Forum Discussion
Anonymous
4 years agoNot applicable
Calculated column to group rows
I have a calculated table with the following fields representing log in sessions. Im trying to group the rows together if: They have the same name ie PR The time between the previous lo...
- 4 years ago
Hi Anonymous ,
According to your description, here's my solution, I create four measures.
Mins Between Logoff (mins) = IF ( MAX ( 'Table'[Rank] ) = 1, "", CALCULATE ( DATEDIFF ( MAXX ( FILTER ( ALL ( 'Table' ), 'Table'[Rank] = MAX ( 'Table'[Rank] ) - 1 && 'Table'[Name] = MAX ( 'Table'[Name] ) ), 'Table'[LogoffTime] ), MAX ( 'Table'[LoginTime] ), MINUTE ) ) )Duration (mins) = DATEDIFF(MAX('Table'[LoginTime]),MAX('Table'[LogoffTime]),MINUTE)SessionID = CALCULATE ( COUNT ( 'Table'[Name] ), FILTER ( ALL ( 'Table' ), 'Table'[Name] = MAX ( 'Table'[Name] ) && [Mins Between Logoff (mins)] >= 20 && 'Table'[Rank] <= MAX ( 'Table'[Rank] ) ) )Total Duration per session (mins) = VAR _Add = ADDCOLUMNS ( ALL ( 'Table' ), "sessionID", [SessionID] ) VAR _Add2 = ADDCOLUMNS ( _Add, "Duration", SUMX ( FILTER ( _Add, [Name] = EARLIER ( [Name] ) && [sessionID] = EARLIER ( [sessionID] ) ), [Duration (mins)] ) ) RETURN SUMX ( FILTER ( _Add2, [Name] = MAX ( 'Table'[Name] ) && [Rank] = MAX ( 'Table'[Rank] ) ), [Duration] )Get the expected result.
I attach my sample below to help you understanding.
Best Regards,
Community Support Team _ kalyjIf this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Fowmy
4 years agoSuper User
Anonymous
Not quite clear, could you show the calculation In Excel and attach the file using Google or One Drive link here?
Anonymous
4 years agoNot applicable
This would be the desired outcome: