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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
PhilTo1
New Member

% split with multiple criteria

Hi,

 

I'm a fairly new user to Power BI, apologies if there is a simple answer to this!

 

I'm working on a payroll report which looks something like

                                                                                     Period 1              Period 2          Period 3   etc.

Employee number   Staff Name 1   Cost Code 1         Value                   Value              Value

                                                         Cost Code 2         Value                   Value              Value

 

Employee number   Staff Name 2   Cost Code 1

                                                         Cost Code 2

 

This part of the report runs absolutely fine but I want to include another table showing the % salary splits. So for example if staff member 1 had a salary of 10,000 split with 8,000 on 1 code and 2,000 on another it would show as 80% and 20%. 

 

The solutions I've seen are all fairly limited in that the filters have been specified by name in the body of the formula  but I have hundreds of staff members and cost codes so this simply isn't feasible.

 

Any help would be massively appreciated! 

 

Thanks in advance

Phil 

1 ACCEPTED SOLUTION
AndrewGould
Frequent Visitor

Hi Phil,

If you wanted the second table to have the same layout as the one you showed (I'm guessing you used a Matrix visual?) you could add a measure which divides the salary for each employee and cost code by the total salary for the employee.  Here's a basic version of a measure which would do that:

 

 

Salary as % of Employee Total Salary = DIVIDE(
    SUM(YourTable[Salary]),
    CALCULATE(
        SUM(YourTable[Salary]),
        REMOVEFILTERS(YourTable[Cost Code])
    )
)

 

 

You can format the measure as a percentage using the Measure Tools tab in the ribbon:

AndrewGould_0-1722588831597.png

 

And when you create the matrix you'll see results similar to this:

AndrewGould_1-1722588862800.png

 

N.B. I used the following mock data:

Staff NamePeriodCost CodeSalary
Employee 1Period 1Cost Code 18000
Employee 1Period 1Cost Code 22000
Employee 2Period 1Cost Code 16000
Employee 2Period 1Cost Code 24000
Employee 1Period 2Cost Code 19000
Employee 1Period 2Cost Code 21000
Employee 2Period 2Cost Code 15000
Employee 2Period 2Cost Code 25000
Employee 1Period 3Cost Code 17500
Employee 1Period 3Cost Code 22500
Employee 2Period 3Cost Code 16500
Employee 2Period 3Cost Code 33500

View solution in original post

5 REPLIES 5
AndrewGould
Frequent Visitor

Hi Phil,

If you wanted the second table to have the same layout as the one you showed (I'm guessing you used a Matrix visual?) you could add a measure which divides the salary for each employee and cost code by the total salary for the employee.  Here's a basic version of a measure which would do that:

 

 

Salary as % of Employee Total Salary = DIVIDE(
    SUM(YourTable[Salary]),
    CALCULATE(
        SUM(YourTable[Salary]),
        REMOVEFILTERS(YourTable[Cost Code])
    )
)

 

 

You can format the measure as a percentage using the Measure Tools tab in the ribbon:

AndrewGould_0-1722588831597.png

 

And when you create the matrix you'll see results similar to this:

AndrewGould_1-1722588862800.png

 

N.B. I used the following mock data:

Staff NamePeriodCost CodeSalary
Employee 1Period 1Cost Code 18000
Employee 1Period 1Cost Code 22000
Employee 2Period 1Cost Code 16000
Employee 2Period 1Cost Code 24000
Employee 1Period 2Cost Code 19000
Employee 1Period 2Cost Code 21000
Employee 2Period 2Cost Code 15000
Employee 2Period 2Cost Code 25000
Employee 1Period 3Cost Code 17500
Employee 1Period 3Cost Code 22500
Employee 2Period 3Cost Code 16500
Employee 2Period 3Cost Code 33500

Thankyou so much, this worked perfectly

Great, happy that it helped!

bhanu_gautam
Super User
Super User

@PhilTo1 , You can create measure for this

First create a new measure for total salary

 

TotalSalary = CALCULATE(SUM('YourTable'[Value]), ALLEXCEPT('YourTable', 'YourTable'[Employee number]))

 

Then for percentage

PercentageSplit = DIVIDE(SUM('YourTable'[Value]), [TotalSalary], 0)

 

In your report, add a table visual.
Add the Employee Number, Staff Name, Cost Code, and Period fields to the table.
Add the Value field to show the salary values.
Add the PercentageSplit measure to show the percentage splits.




Did I answer your question? Mark my post as a solution! And Kudos are appreciated

Proud to be a Super User!




LinkedIn






Hi, thanks for the superquick response. This almost worked but the % split was a total of the cost across all periods, not by period.

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

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