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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends September 15. Request your voucher.

Reply
Anonymous
Not applicable

Calculations between two fact tables

Dear PBI-Community,

 

I have a data model that looks something like this:

Unbenannt.PNG

 

My main Problem is calculating between the two fact tables. I have to multiply the hours worked per month with the corresponding hourly wage for each employee and i haven't figured out how to do that. The goal is to multiply the values of "hours worked" and "hourly wage" where the date and Employee_ID are similar between both fact tables.

 

Additional Info: I have to use direct query and can't change the structure of the data in the data warehouse. My current strategy is to generate a new primary key (YYYY.MM.Employee_ID) and directly connect the two fact tables but I think there has to be a "cleaner" way. 

 

Thank for the help,

Jakob

1 ACCEPTED SOLUTION
Anonymous
Not applicable

@Anonymous 

I created some data:

Employee Fact Table:

Vpazhenmsft_3-1630056238114.png

Employee Wage Fact Table

Vpazhenmsft_4-1630056243783.png

Here are the steps you can follow:

1. Create calculated column.

Month = MONTH('Employee Fact Table'[Date])

2. Create measure.

Measure =

var _1=CALCULATE(SUM('Employee Fact Table'[Hour worked]),FILTER(ALL('Employee Fact Table'),'Employee Fact Table'[Employee_ID]=MAX('Employee Fact Table'[Employee_ID])&&'Employee Fact Table'[Month]=MAX('Employee Fact Table'[Month])))

var _2=CALCULATE(SUM('Employee Wage Fact Table'[Hourlywage]),FILTER(ALL('Employee Wage Fact Table'),'Employee Wage Fact Table'[Employee_ID]=MAX('Employee Fact Table'[Employee_ID])&&'Employee Wage Fact Table'[Month]=MAX('Employee Fact Table'[Month])))

return

_1 * _2

3. Result:

Vpazhenmsft_5-1630056287147.png

If it does not meet your expected results, can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.

 

Best Regards,

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

@Anonymous 

I created some data:

Employee Fact Table:

Vpazhenmsft_3-1630056238114.png

Employee Wage Fact Table

Vpazhenmsft_4-1630056243783.png

Here are the steps you can follow:

1. Create calculated column.

Month = MONTH('Employee Fact Table'[Date])

2. Create measure.

Measure =

var _1=CALCULATE(SUM('Employee Fact Table'[Hour worked]),FILTER(ALL('Employee Fact Table'),'Employee Fact Table'[Employee_ID]=MAX('Employee Fact Table'[Employee_ID])&&'Employee Fact Table'[Month]=MAX('Employee Fact Table'[Month])))

var _2=CALCULATE(SUM('Employee Wage Fact Table'[Hourlywage]),FILTER(ALL('Employee Wage Fact Table'),'Employee Wage Fact Table'[Employee_ID]=MAX('Employee Fact Table'[Employee_ID])&&'Employee Wage Fact Table'[Month]=MAX('Employee Fact Table'[Month])))

return

_1 * _2

3. Result:

Vpazhenmsft_5-1630056287147.png

If it does not meet your expected results, can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.

 

Best Regards,

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

amitchandak
Super User
Super User

@Anonymous , A measure like this

Sumx(summarize('Employee Fact', 'Employee Dim'[Employee], 'Date'[Date] , "_1", sum('Employee Fact'[hours worked]) , "_2" , sum('Employee Wages'[hourly wage] )), [_1]*[_2])

 

Do calculation changes as per need

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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