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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
RobertasUC
Frequent Visitor

Measure for calculating percentage from total hours

Hello,

 

I have an issue with measure, which when added to visual (table or matrix) does not calculate properly. I need this measure to show percentage from total hours by driver1 name multiplied by fixed_cost. Instead, this measure for percentage calculation simply takes total row hours and divide from same total row hours (instead of dividing from total hours grouped by driver1 name).

 

RE ES Fixed Costs =
VAR SelectedMonths = VALUES('RE ES Query'[Month])
VAR SelectedYear = SELECTEDVALUE('RE ES Query'[Year])
VAR TotalHoursPerDriver =
    SUMX(SUMMARIZE('RE ES Query','RE ES Query'[Driver1 Name]),CALCULATE(SUM('RE ES Query'[Hours]))
    )
RETURN

    -CALCULATE(
        SUM('Contribution Rates'[fixed_cost]),
        'Contribution Rates',
        'Contribution Rates'[division] = "OTREAST",
        'Contribution Rates'[year] = SelectedYear,
        'Contribution Rates'[month] IN SelectedMonths
    ) * sum('RE ES Query'[Hours])/TotalHoursPerDriver
 
 
RobertasUC_0-1708440194884.png

 

2 REPLIES 2
RobertasUC
Frequent Visitor

Thanks, @amitchandak, but this is not what I'm looking for. Adding more details:

 

Let's say in my slicer, week 7 is selected which is from 02/11/2024 to 02/17/2024. So for fixed costs calculation, I need to take fixed costs value from Contribution Rates table for February. Now, since only week 7 is selected, I want to calculate based on the following logic:

  1. Driver 1 in week 7 has 4 rows with hours 64+49+4+5 = 167.
  2. I need to allocate fixed cost (which is in the table Contribution Rates and it is weekly) and the allocation would be for each row. For example, first row = 64 (first row hours) / 167 (total week hours) * 1499 (OTREAST fixed cost).

 

Contribution Rates table snip:

RobertasUC_2-1708500076490.png

 

 

RE ES Query table snip:

RobertasUC_1-1708499820195.png

 

 

amitchandak
Super User
Super User

@RobertasUC , You can create a calculated column in RE ES Query,if Month and year is a key, or add more columns as per need

new column

Total = 'RE ES Query'[Hours] * Maxx(FIlter('Contribution Rates',   'Contribution Rates'[Month] = 'RE ES Query'[Month] &&  'Contribution Rates'[year]  = 'RE ES Query'[Year] ), 'Contribution Rates'[fixed_cost])

 

or with division

 

Total = 'RE ES Query'[Hours] * Maxx(FIlter('Contribution Rates', 'Contribution Rates'[Month] = 'RE ES Query'[Month] && 'Contribution Rates'[year] = 'RE ES Query'[Year] && 'Contribution Rates'[Division] = 'RE ES Query'[Division] ), 'Contribution Rates'[fixed_cost])

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
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 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.