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

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.

Reply
Anonymous
Not applicable

Dax for sum of distinct values grouped by multiple columns

Hi community,

 

Following is my sample dataset, I want to add a column "Total Sal"(already added in the following snapshot) that is total of distinct salaries of employees. Grouped by Dept, position,empcode.


distinct sum.PNG

 

 

 

 

 

 

I have tried few DAX, but nothing is working.

Your help is much appretiated.

Many thanks,

Meena

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Another community member could probably improve on this, but I did this by changing the grain of the table, i.e. removing the qualification column and consolidating the duplicates. You can do this in a separate table by referencing the query in Query Editor.

Then you can add in the measure:

Total Departmental Salary =
CALCULATE ( SUM ( Salaries[Salary] ), ALLEXCEPT ( Salaries, Salaries[Dept] ) )

 

View solution in original post

2 REPLIES 2
sivapandi
Helper I
Helper I

Table =
SUMMARIZE (
    EmpSalary,
    EmpSalary[Dept],
    EmpSalary[empcode],
    EmpSalary[Position],
    "TotalSal", DISTINCT ( EmpSalary[salary] )
)

Hai Meena.,

Please try this....

Anonymous
Not applicable

Another community member could probably improve on this, but I did this by changing the grain of the table, i.e. removing the qualification column and consolidating the duplicates. You can do this in a separate table by referencing the query in Query Editor.

Then you can add in the measure:

Total Departmental Salary =
CALCULATE ( SUM ( Salaries[Salary] ), ALLEXCEPT ( Salaries, Salaries[Dept] ) )

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.