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

Next up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now

Reply
ronaldbalza2023
Continued Contributor
Continued 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 add the department field (_EmployeeDetail[Department] ) to my visualization, the percentage gets divided incorrectly across departments.


Here’s the current DAX measure:

 

 

% SalaryRangeHigh = 
VAR TotalActiveEmployees =
  CALCULATE(
    COUNTROWS(_EmployeeDetail),
    _EmployeeDetail[EmploymentStatus] = "Active",
    NOT ISBLANK(_EmployeeSalary[ Salary ])
  )
VAR ActiveEmployeesHigherRange =
  CALCULATE(
    COUNTROWS(_EmployeeDetail),
    _EmployeeDetail[EmploymentStatus] = "Active",
    NOT ISBLANK(_EmployeeSalary[ Salary ]),
    FILTER(
      _EmployeeSalary,
      _EmployeeSalary[ Salary ] >= _EmployeeSalary[SalaryRangeHigh]
    )
  )
RETURN 
  DIVIDE(ActiveEmployeesHigherRange, TotalActiveEmployees, 0)

 

Here's the sample pbix file
SampleData.pbix 

Thanks in advance for your help!

 
1 ACCEPTED SOLUTION

@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)

 

View solution in original post

6 REPLIES 6
twofingertyper
Helper III
Helper III

Sorry, had just read the chapter in the guide to DAX and it sounded similar to an example they provided. The filter you provided within the CALCULATE function would still be applied, it just removes any additional filters that may be impacting on the measure. 

 

Apologies if you knew all this already, I am slowly learning things and find it a lot easier currently to work with examples/data rather than just the code, but hopefully someone will be along that knows more than me and can assist. 

 

(sorry, just noticed you uploaded the example, will take a look!)

 

Good luck with it! 

twofingertyper
Helper III
Helper III

If you removed the filters as part of the calculation; so adding in - I think - ALL (_EmployeeDetail) after the COUNTROWS, does that help? 

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.

Do you have the figures you want? As I can get these:

twofingertyper_0-1711028663381.png

By using the ALL on both tables.

Hi @twofingertyper , on point. How did you achieved it? Thanks 🙂

@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)

 

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.