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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
AmiraBedh
Super User
Super User

Remove groups and keep values

I have a simple table where I put Department, Number of Employees and Salary Expenses like below :

 

DeptID  Number_of_Employees Salary_Expenses

1                   159                                 100000

2                   240                                 135000

3                     55                                  78999

 

The DeptID is coming from the Department table

The Number_of_Employees is a measure based on the fact table HR_Anatlytics :

Number_of_Employees := DISTINCTCOUNT(HR_Anatlytics[EmployeeSK])

The Salary_Expenses is a measure based on the fact table HR_Anatlytics :

Salary_Expenses := SUM(HR_Anatlytics[Salary])

 

The relationship between the Department dimension and the HR_Anatlytics is one to many.

 

My expected output is like below, I want to remove the groups and keep values

 Number_of_Employees Salary_Expenses

 159                                 100000

 240                                 135000

55                                  78999

 


Proud to be a Power BI Super User !

Microsoft Community : https://docs.microsoft.com/en-us/users/AmiraBedhiafi
Linkedin : https://www.linkedin.com/in/amira-bedhiafi/
StackOverflow : https://stackoverflow.com/users/9517769/amira-bedhiafi
C-Sharp Corner : https://www.c-sharpcorner.com/members/amira-bedhiafi
Power BI Community :https://community.powerbi.com/t5/user/viewprofilepage/user-id/332696
1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @AmiraBedh,

Current power bi does not support using measure expressions as category/axis fields to expand other measure calculations. (measure expressions are calculated based on the row contexts so it required a category/group field to define the calculate ranges)

In my opinion, I think you need to use calculate column instead:

Number_of_Employees :=
CALCULATE (
    DISTINCTCOUNT ( HR_Anatlytics[EmployeeSK] ),
    FILTER ( HR_Anatlytics, [DeptID] = EARLIER ( HR_Anatlytics[DeptID] ) )
)

In addition, you can also try to create a new calculated table that used summary records:

NewTable =
SELECTCOLUMNS (
    SUMMARIZE (
        HR_Anatlytics,
        [DeptID],
        "Number_of_Employees", DISTINCTCOUNT ( HR_Anatlytics[EmployeeSK] ),
        "Salary_Expenses", SUM ( HR_Anatlytics[Salary] )
    ),
    "Number_of_Employees", [Number_of_Employees],
    "Salary_Expenses", [Salary_Expenses]
)

If the above formulas do not help, can you please share a pbix or some dummy data that keep raw data structure with expected results? It should help us quickly clarify your scenario and test to coding formula.

How to Get Your Question Answered Quickly  

Regards,

Xiaoxin Sheng

View solution in original post

5 REPLIES 5
smpa01
Super User
Super User

@AmiraBedh  Number_of_Employees and Salary_Expenses are both measures. In DAX Measures are calculated based on what is available in the filter context. If the axis/filter context is removed, the measures will not evaluate.

 

The workaround is to create equivalent calculated columns, cause they can work as axis.

Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs

@smpa01  I tried to create a calculated column like below : 

Salary_Expenses := SUM(HR_Anatlytics[Salary])

but it is not working 


Proud to be a Power BI Super User !

Microsoft Community : https://docs.microsoft.com/en-us/users/AmiraBedhiafi
Linkedin : https://www.linkedin.com/in/amira-bedhiafi/
StackOverflow : https://stackoverflow.com/users/9517769/amira-bedhiafi
C-Sharp Corner : https://www.c-sharpcorner.com/members/amira-bedhiafi
Power BI Community :https://community.powerbi.com/t5/user/viewprofilepage/user-id/332696

@AmiraBedh  It should not work because you are using the same Measure expression for the calculated column and hoping it returns the same. Wrap this in a CALCULATE

Salary_Expenses= CALCULATE(SUM(HR_Anatlytics[Salary]))

 

Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs

Still not working. It is giving the same value for all the columns.


Proud to be a Power BI Super User !

Microsoft Community : https://docs.microsoft.com/en-us/users/AmiraBedhiafi
Linkedin : https://www.linkedin.com/in/amira-bedhiafi/
StackOverflow : https://stackoverflow.com/users/9517769/amira-bedhiafi
C-Sharp Corner : https://www.c-sharpcorner.com/members/amira-bedhiafi
Power BI Community :https://community.powerbi.com/t5/user/viewprofilepage/user-id/332696
Anonymous
Not applicable

Hi @AmiraBedh,

Current power bi does not support using measure expressions as category/axis fields to expand other measure calculations. (measure expressions are calculated based on the row contexts so it required a category/group field to define the calculate ranges)

In my opinion, I think you need to use calculate column instead:

Number_of_Employees :=
CALCULATE (
    DISTINCTCOUNT ( HR_Anatlytics[EmployeeSK] ),
    FILTER ( HR_Anatlytics, [DeptID] = EARLIER ( HR_Anatlytics[DeptID] ) )
)

In addition, you can also try to create a new calculated table that used summary records:

NewTable =
SELECTCOLUMNS (
    SUMMARIZE (
        HR_Anatlytics,
        [DeptID],
        "Number_of_Employees", DISTINCTCOUNT ( HR_Anatlytics[EmployeeSK] ),
        "Salary_Expenses", SUM ( HR_Anatlytics[Salary] )
    ),
    "Number_of_Employees", [Number_of_Employees],
    "Salary_Expenses", [Salary_Expenses]
)

If the above formulas do not help, can you please share a pbix or some dummy data that keep raw data structure with expected results? It should help us quickly clarify your scenario and test to coding formula.

How to Get Your Question Answered Quickly  

Regards,

Xiaoxin Sheng

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

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