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.
Hi
I have a dax for a KPI that I can’t seem to make work. What I want is to count, the number og employees that has been active every month in the filtered period. The data looks like this:
I figured that I need to know how many months are in the period, I did that this way
V – Number of months= CALCULATE(DISTINCTCOUNT('HRPM SKF'[ID]), ALLEXCEPT('HRPM SKF','HRPM SKF'[EOM]))
This work fine, but I can’t make a dax that counts how many employees that has been active every month in the filtered period.
I tried with:
V – Number of employees =
Var months = V – Number of months
Var number = DISTINCTCOUNT('HRPM SKF'[Medarbejdernr-W (HRPM)])
Return
if(number=moths,1,0)
This works fine, when I do a list with employee IDs in it. But not when I aggregate in a KPI.
Jesper
Solved! Go to Solution.
Hi,
Please check the below picture and the attached pbix file.
I suggest having a dim-calendar table like below.
Active employee count: =
VAR employeetable =
ADDCOLUMNS (
VALUES ( Data[ID] ),
"@startdate", CALCULATE ( MIN ( Data[EOM] ) ),
"@enddate", CALCULATE ( MAX ( Data[EOM] ) )
)
RETURN
COUNTROWS (
FILTER (
employeetable,
[@startdate] <= MAX ( 'Calendar'[Date] )
&& [@enddate] >= MIN ( 'Calendar'[Date] )
)
)
If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.
Hi,
Please check the below picture and the attached pbix file.
I suggest having a dim-calendar table like below.
Active employee count: =
VAR employeetable =
ADDCOLUMNS (
VALUES ( Data[ID] ),
"@startdate", CALCULATE ( MIN ( Data[EOM] ) ),
"@enddate", CALCULATE ( MAX ( Data[EOM] ) )
)
RETURN
COUNTROWS (
FILTER (
employeetable,
[@startdate] <= MAX ( 'Calendar'[Date] )
&& [@enddate] >= MIN ( 'Calendar'[Date] )
)
)
If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.
Yes. however i only wanna count them if they have been active every month in the periode. Lets say i set my period filter to "From 30-06-2021 to 31-07-2021" then it should 2. Because only James and Ivan have been acticve in both months
Then you just need to create new measure
Number Of Employees =
DISTINCTCOUNT('HRPM SKF'[ID])
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
41 | |
21 | |
21 | |
14 | |
14 |
User | Count |
---|---|
42 | |
39 | |
33 | |
19 | |
18 |