Forum Discussion
Discharge department
- 3 years ago
bdeleur
For now this is what I can provide you. The difference between Count 2 and Count 3 is that count 3 shall not count discharged from same department unless there is a discharge date. The difference shall not be noticed using the sample data as there are no blanks in the end date.
bdeleur
Please try
Count =
SUMX (
VALUES ( 'Table'[Reference] ),
VAR CurrentTable =
CALCULATETABLE ( 'Table' )
VAR FirstRecord =
TOPN ( 1, CurrentTable, 'Table'[Start date], ASC )
VAR LastRecord =
TOPN ( 1, CurrentTable, 'Table'[Start date] )
VAR FirstDepartment =
MAXX ( FirstRecord, 'Table'[Department] )
VAR LastDepartment =
MAXX ( LastRecord, 'Table'[Department] )
VAR DischargeDate =
MAXX ( LastRecord, 'Table'[End Date] )
RETURN
IF (
AND ( FirstDepartment = LastDepartment, DischargeDate <> BLANK () )
&& MAX ( 'To'[Department] ) = LastDepartment
&& MAX ( 'FROM'[Department] ) = FirstDepartment,
1
)
)Now the matrix stays empty when I apply the code in your file.
- tamerj13 years ago
Community Champion
bdeleur
I guess you are right. Sorry did not test. Pleas tryCount = SUMX ( VALUES ( 'Table'[Reference] ), VAR CurrentTable = CALCULATETABLE ( 'Table' ) VAR FirstRecord = TOPN ( 1, CurrentTable, 'Table'[Start date], ASC ) VAR LastRecord = TOPN ( 1, CurrentTable, 'Table'[Start date] ) VAR FirstDepartment = MAXX ( FirstRecord, 'Table'[Department] ) VAR LastDepartment = MAXX ( LastRecord, 'Table'[Department] ) VAR DischargeDate = MAXX ( LastRecord, 'Table'[End Date] ) RETURN IF ( OR ( FirstDepartment = LastDepartment && DischargeDate <> BLANK (), MAX ( 'To'[Department] ) = LastDepartment && MAX ( 'FROM'[Department] ) = FirstDepartment ), 1 ) )- bdeleur3 years ago
Helper III
I get some information now. But I'm trying to understand what I see.
I see the movements for every department but I don't see the next department.
I think I didn't meanson that well enough, sorry for that. And I like to see it like this:
This is when I selected/slice or filter department A
- tamerj13 years ago
Community Champion
bdeleur
For now this is what I can provide you. The difference between Count 2 and Count 3 is that count 3 shall not count discharged from same department unless there is a discharge date. The difference shall not be noticed using the sample data as there are no blanks in the end date.