Search code examples
ssaspowerbidaxssas-tabular

Can we combine 2 measures into one?


My data view is look like below:

enter image description here

To do the SUM of salary group by employee id I have created 2 measure as below:

Measure = MAXX(DISTINCT(Employee1[EmployeeId]),MAX(Employee1[Salary]))
SumSalary = SUMX(DISTINCT(Employee1[Salary]),[Measure])

I tried as below but it does not work. Showing wrong values in Power BI.

SumSalary = SUMX(DISTINCT(Employee1[Salary]),MAXX(DISTINCT(Employee1[EmployeeId]),MAX(Employee1[Salary])))

Is there any other way to combine those measures?


Solution

  • I would try something along these lines:

    TotalSalary = SUMX(
                      SUMMARIZE(Employee1,
                          Employee1[EmployeeId],
                          "EmployeeSalary", MAX(Employee1[Salary])),
                      [EmployeeSalary])
    

    This first groups them by EmployeeId, taking the maximum salary for that ID, and then sums the salaries for each employee.