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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
Anonymous
Not applicable

Sum of a column based on a value in a related table

Dear group, please help me with my predicament.

I have two related tables Projects 

ProjectBudgetContractedHours
A  47280.00                 283.00
B  14240.00                   89.00
C319940.00               5017.37
D352416.00               4635.12
E102216.00                 653.85

And Timesheets

EmployeeProjectChargeable
1A0
2B30
3C35
4D0
5A0
1B185
2C159.25
3D0
4A0
5B23
1C0
2D67.5
3A0
4B39.5
5C18.5

 

And I want to do couple of things. 
First a measure which calculates all chargeable hours.

 

 

ChargeableHours = SUM(Timesheets[Chargeable])

 

 

Because the tables are related (by projectid) I can use it in a table visual (for projects) and it will correctly show all chargeable hours for each project.

ProjectBiudgetContractedChargeableHours
A  47280.00       283.00                          0
B  14240.00         89.00                   277.5
C319940.00     5017.37                 212.75
D352416.00     4635.12                     67.5
E102216.00       653.85 

What I am looking for is an average contracted rate for all those projects which have registered chargeable hours in the timesheet table. 
I struggle with the next step, which is a measure which will sum all the Budget values from Projects, but only, where ChargeableHours were more than 0 and a measure which will do the same with contracted hours under the same circumstances. I could then achieve what I want by dividing the measure 1 by 2. 
Any thoughts?

2 REPLIES 2
Jihwan_Kim
Super User
Super User

Hi, @Anonymous 

I am not sure how your logic for the last result looks like, but please check the below picture and the sample pbix file's link down below.

 

Picture2.png

 

 

Budget Total =
SUMX (
Timesheets,
Timesheets[Chargeable] * RELATED ( Projects[Budget] )
/ RELATED ( Projects[ContractedHours] )
)
 
 
 
 

Hi, My name is Jihwan Kim.


If this post helps, then please consider accept it as the solution to help other members find it faster, and give a big thumbs up.


Linkedin: linkedin.com/in/jihwankim1975/

Twitter: twitter.com/Jihwan_JHKIM


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.
Anonymous
Not applicable

Hi Jihwan,

Thanks for your reply,

I am looking for 3 measures.

1. A total of budgets for those projects which have registered chargeable hours in the timesheet table. SUM of Projects Budget WHERE ChargeableHours >0
2. A total of Contracted hours for those projects which have registered chargeable hours in the timesheet table. SUM of Projects Contracted WHERE ChargeableHours >0
3. An average contracted rate for those projects which have registered chargeable hours in the timesheet table. 1 divided by 2

EDIT: Those are three independent measures and I don't intend to add them to any of the columns of the table visual.

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors