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

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

 

1 ACCEPTED SOLUTION
edhans
Super User
Super User

Here you go:

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

 

2020-03-27_13-28-34.png

 

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.



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting

View solution in original post

6 REPLIES 6
edhans
Super User
Super User

Here you go:

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

 

2020-03-27_13-28-34.png

 

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.



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting
Anonymous
Not applicable

Thank you! Works perfect 😀

Great @Anonymous . Glad to help.



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting
Anonymous
Not applicable

Hi again, I am trying to do this again for a different report and I am getting an error, the column 'Department ID' does exist in the Budget table so I am really confused by this 

 

Department ID.PNG

 

I am trying to accomplish this:

 

Department IDOperating FTEsTotal Operating FTEs
2213451.01.5
2213450.51.5
2213561.02.0
2213561.02.0
2217891.02.5
2217891.02.5
2217890.52.5

 

@edhans 

You have to specify the table, then use MAX to convert it to a scalar value.

VAR DeptID = MAX(TableName[Department ID])


Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting
Anonymous
Not applicable

You're a life saver!

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.