Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Calculate Rolling active members

Hi experts,

 

I'm new to Power BI annd DAX, but I'm struggling with a simple calculation. I am trying to calculate the rolling active members for a HR Analysis, depending on selected date of a slicer.

 

Emp ID Start             End              S      Pos   Name     Max ST Date Act   Inact      JoinDate     LeaveDate

110/01/201110/01/201501001Pepe11/01/20150010/01/2011 
111/01/201501/01/999931002Pepe11/01/20151010/01/2011 
203/05/200003/07/200901002Pedro28/10/20160003/05/2000 
204/07/200927/10/20160321Pedro28/10/20160003/05/2000 
228/10/201601/01/999931001Pedro28/10/20161003/05/2000 
303/06/201901/01/999931001Daniel03/06/20191003/06/2019 
407/11/201107/11/20130298Maria07/11/20110107/11/201107/11/2013
509/03/201609/05/201601001Marta10/05/20180009/03/2016 
510/05/201801/01/99993321Marta10/05/20181009/03/2016 

 

And the dax formula:

RollingActive =
   CALCULATE (
   DISTINCTCOUNT ( Sheet1[Emp ID] );
   FILTER ( ALL ( Sheet1[JoinDate] ); Sheet1[JoinDate] <= [selected date] )
)
 
Report.png
 
However, it is not returning any value. The spected output in this case should be 3 (as Emp ID 1,2 and 4 were active in that selected date)
What I'm doing wrong?
1 ACCEPTED SOLUTION
v-juanli-msft
Community Support
Community Support

Hi @Anonymous 

Create a calendar table

calendar = FILTER(ADDCOLUMNS(CALENDARAUTO(),"year",YEAR([Date]),"month",FORMAT([Date],"mmmm")),DAY([Date])=1)

Don't create any relationship between this calendar table and other table

 

Create measures in Sheet5

selected = SELECTEDVALUE('calendar'[Date])

RollingActive = CALCULATE(DISTINCTCOUNT(Sheet5[Emp ID]),FILTER(Sheet5,Sheet5[JoinDate]<=[selected]))

Add [year],[month] from "calendar" table to the slicer

11.png

 

 

Best Regards
Maggie

 

Community Support Team _ Maggie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

1 REPLY 1
v-juanli-msft
Community Support
Community Support

Hi @Anonymous 

Create a calendar table

calendar = FILTER(ADDCOLUMNS(CALENDARAUTO(),"year",YEAR([Date]),"month",FORMAT([Date],"mmmm")),DAY([Date])=1)

Don't create any relationship between this calendar table and other table

 

Create measures in Sheet5

selected = SELECTEDVALUE('calendar'[Date])

RollingActive = CALCULATE(DISTINCTCOUNT(Sheet5[Emp ID]),FILTER(Sheet5,Sheet5[JoinDate]<=[selected]))

Add [year],[month] from "calendar" table to the slicer

11.png

 

 

Best Regards
Maggie

 

Community Support Team _ Maggie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.