Forum Discussion
ronaldbalza2023
2 years agoContinued Contributor
Incorrect Percentage - DAX
Hi everyone, I’m hoping to get some assistance with a DAX measure I created to calculate the percentage of employees in the higher salary range. The overall percentage seems accurate, but when I ...
- 2 years ago
ronaldbalza2023 - as mentioned, just adding in ALL. so your measure became:
% SalaryRangeHigh = VAR TotalActiveEmployees = CALCULATE( COUNTROWS(_EmployeeDetail), ALL (_EmployeeDetail) , ALL (_EmployeeSalary) , _EmployeeDetail[EmploymentStatus] = "Active", NOT ISBLANK(_EmployeeSalary[ Salary ]) ) VAR ActiveEmployeesHigherRange = CALCULATE( COUNTROWS(_EmployeeDetail), ALL (_EmployeeDetail), ALL (_EmployeeSalary) , _EmployeeDetail[EmploymentStatus] = "Active", NOT ISBLANK(_EmployeeSalary[ Salary ]), FILTER( _EmployeeSalary, _EmployeeSalary[ Salary ] >= _EmployeeSalary[SalaryRangeHigh] ) ) RETURN DIVIDE(ActiveEmployeesHigherRange, TotalActiveEmployees)
twofingertyper
2 years agoHelper III
If you removed the filters as part of the calculation; so adding in - I think - ALL (_EmployeeDetail) after the COUNTROWS, does that help?
ronaldbalza2023
2 years agoContinued Contributor
Hi twofingertyper, thanks for taking the time on this, appreciate it. That doesn't help as the main measure was to filter all the employees in the higher salary range.
- twofingertyper2 years agoHelper III
Do you have the figures you want? As I can get these:
By using the ALL on both tables.
- ronaldbalza20232 years agoContinued Contributor
Hi twofingertyper , on point. How did you achieved it? Thanks 🙂
- twofingertyper2 years agoHelper III
ronaldbalza2023 - as mentioned, just adding in ALL. so your measure became:
% SalaryRangeHigh = VAR TotalActiveEmployees = CALCULATE( COUNTROWS(_EmployeeDetail), ALL (_EmployeeDetail) , ALL (_EmployeeSalary) , _EmployeeDetail[EmploymentStatus] = "Active", NOT ISBLANK(_EmployeeSalary[ Salary ]) ) VAR ActiveEmployeesHigherRange = CALCULATE( COUNTROWS(_EmployeeDetail), ALL (_EmployeeDetail), ALL (_EmployeeSalary) , _EmployeeDetail[EmploymentStatus] = "Active", NOT ISBLANK(_EmployeeSalary[ Salary ]), FILTER( _EmployeeSalary, _EmployeeSalary[ Salary ] >= _EmployeeSalary[SalaryRangeHigh] ) ) RETURN DIVIDE(ActiveEmployeesHigherRange, TotalActiveEmployees)