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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

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])

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Prices go up Feb. 11th.

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

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