Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago
Solved

Column to Sum data based on another column

Hello everyone,

 

First off I am new to Power BI so I apoligize if this is an easy answer. I tried googling and really could not come up with what I am looking for.

 

I need too add a Column to my Budget table called "PBL Total Salary" to display the sum of "Total Budgeted Salary" for each "Position Number"

 

All of this is coming from the same table.

 

Thank you in advance!

 

Example:

Position NumberTotal Budgeted SalaryPBL Total Salary
00072481              9,326.72            15,808.00
00072481              5,216.64            15,808.00
00072481              1,264.64            15,808.00
00005962              7,752.84            13,140.40
00005962              4,336.33            13,140.40
00005962              1,051.23            13,140.40
00003291            24,803.25            42,039.40
00003291            13,873.00            42,039.40
00003291              3,363.15            42,039.40

 

  • Here you go:

    Total Budget Salary = 
    VAR PositionNo = [Position Number]
    RETURN
    SUMX(
        FILTER(
            Budget,
            [Position Number] = PositionNo
        ),
        [Total Budgeted Salary]
    )

     

     

    the PostionNo Variable captures the current position number, then the FILTER statement compares that to the current row it is on in the table. It moves through each row one at a time.

6 Replies

  • edhans's avatar
    edhans
    Community Champion

    Here you go:

    Total Budget Salary = 
    VAR PositionNo = [Position Number]
    RETURN
    SUMX(
        FILTER(
            Budget,
            [Position Number] = PositionNo
        ),
        [Total Budgeted Salary]
    )

     

     

    the PostionNo Variable captures the current position number, then the FILTER statement compares that to the current row it is on in the table. It moves through each row one at a time.

    • Anonymous's avatar
      Anonymous
      Not applicable

      Thank you! Works perfect ğŸ˜€

      • edhans's avatar
        edhans
        Community Champion

        Great Anonymous . Glad to help.