Forum Discussion
Count staff that move between roles
- 4 years ago
Hi jmilne320
I hope this is what you're looking forActive Staff = CALCULATE ( COUNTROWS ( FILTER ( CALCULATETABLE ( Pilots, CROSSFILTER ( Pilots[Staff Number], events[Staff Number], BOTH ) ), MAXX ( RELATEDTABLE ( Events ), Events[Date] ) <= MAX ( 'Date'[Date] ) ) ), 'Date'[date] <= MAX ('Date'[date] ) ) - 4 years ago
Hi jmilne320
First you need to create a new column for end date in the vents table:end date = MINX ( FILTER ( CALCULATETABLE ( Events, ALLEXCEPT ( Events, Events[Staff Number] ) ), Events[start date] > EARLIER ( Events[start date] ) ), Events[start date] )Then you need to deactivate or delete the relationship with the date table
The following would be the measure
Active Staff = VAR CurrentDate = MAX ( 'Date'[date] ) RETURN COUNTROWS ( FILTER ( Events, VAR StartDate = Events[start date] VAR EndtDate = COALESCE ( Events[End date], DATE ( 3000, 1, 1 ) ) RETURN StartDate <= CurrentDate && EndtDate >= CurrentDate ) )
Hi jmilne320
Please try
Active Staff =
COUNTROWS (
FILTER (
CALCULATETABLE (
Pilots,
CROSSFILTER ( Pilots[Staff Number], events[Staff Number], BOTH )
),
MAXX ( RELATEDTABLE ( Events ), Events[Date] ) = MAX ( 'Date'[Date] )
)
)
Hi tamerj1, thanks for very much for your reply!
This formula is definitely along the lines of what I am looking for, although it returns no value until I change the MAX('Date'[Date]) to MAX('Events'[Date]).
I have uploaded a test .pbix file to make it easier for you to inspect:
My next problem is that the formula does not return a cumulative count of staff, only a count of staff on the date period when they changed posting.
Thank you so much for your assistance, if you need any further information just let me know.
Kind regards,
James