Forum Discussion
jmilne320
4 years agoFrequent Visitor
Count staff that move between roles
Hi All, I am new to Power BI and I am struggling to create a measure that counts staff of different categories on a particular date. My model is as below: The 'Events' table records...
- 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 ) )
jmilne320
4 years agoFrequent Visitor
Ahhhhh I can't begin to explain how excited I am! This is exactly what I have been trying to achieve for weeks, I'm very thankful for your help. It is very interesting to see how you went about troubleshooting my problem and the formulas you employed along the way. I'm looking forward to further exploring Power BI!
Kind regards,
James
tamerj1
Community Champion
4 years agoGreat! I'm gladto hear that!
Would you please consider marking the latest reply as acceptable solution?