I am new to PowerBI, so not sure it I create a measure incorrectly or my data model is inefficient.
I am working on creating a dashboard that aims to count "key" employees based on the evaluation matrix : each employee estimates his expertise for each skill on the level from 1 to 5 where 1 - Elementary 2 - Limited 3 - Independent 4 - Advanced 5 - Expert
The matrix : Matrix
The matrix is then unpivoted in PowerQuery and other tables are added so the final data model in PowerBI looks like this (all relationships one sided and active): model
Need shows how much a department needs this skill : 1 no need, 2 average, 3 strong.
I want to calculate the number of "key" employees:
- To master the skill = to have more than 3 on the level of expertise for this skill
- Key employee is an employee that masters the skill that is mastered by less than 4 employees and that is needed on level = 2 or 3). So 3 conditions:
- Key employee has Matrix[Skill level] >= 3
- On the skill with Need[Need] > 1
- And Number of employeed with Matrix[Skill level] >= 3 on the skill with Need[Need] > 1 is less than 4.
On the report view page I have a slicer filter Departments[DepartmentID]. The need for the skill is aggregated by skill and equals MAX need for this skill of all departments. So when I change the filter I want my need for the skills to change too. Number of employees should be affected by department slicer too.
I tried creating a measure of "number of key employees" that is affected by department slicer on the need and employees level but it does not work:
nb =
VAR SummaryNeed = ADDCOLUMNS(
SUMMARIZE(Need,'Skills'[Skill_ID]),
"maxneed",CALCULATE(MAX(Need[Need])))
VAR SummSkill = NATURALINNERJOIN ( 'Skills', FILTER(SummaryNeed, [maxneed]>1 ))
VAR SummaryMatrix = ADDCOLUMNS(
SUMMARIZE(Matrix,'Skills'[Skill_ID]),
"nbexp",CALCULATE(DISTINCTCOUNT(Matrix[Employee_ID])+0
, Matrix[Skill_level]>=3)
)
VAR jointbl = NATURALINNERJOIN( SummSkill, SummaryMatrix )
RETURN CALCULATE(SUMX(jointbl, [nbexp]), FILTER(jointbl, [nbexp]<4))
Could you please suggest solutions how to get this number dynamically changed for the report ?