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
TK12345
Resolver I
Resolver I

How to calculate the percentage of {Hours worked} from your top 10 customers over selected period

Hi all,

I have a question about a calculation that needs to calculate the hours worked for the top 10 customers. The top 10 needs to be based on 13 months, so 2022-06 till 2023-06. So over that period I need to know the sum of the hours that were worked for that customer. I visualize it in a matrix so for example, for period 2022-06 I can have 10 customers that were not the best customers for that exact period. But over all, they were the best customers over 13 months. 

So I need to my 10 best customers over the 13 months, and for that customers I need to know the sum of hours for the period in my matrix. 
I have a extra calendar table so by selecting 2023-06 as filter I get the 13 months I need. The visual in my picture is just filterd for the top 10 in visual level filter. But for my measure it needs to be calculated in a variable. 

So variable 1 needs to be total amount of hours. So that is just my measure. 

Variable 2 needs to be a variable that needs to calculate the amount of hours the Customers in my top 10 (over 13 months) made in the period in my matrix. 

TK12345_0-1702039288633.png

So I need to know how to calculate the percentage per month. I can remake the 2100 in my first column, that is just the whole total. But i need to know how many hours were made by my top 10 (over all the 13 months) in that period.

Who could help me out?

 

2 REPLIES 2
v-yifanw-msft
Community Support
Community Support

Hello @TK12345 ,

 

Thank you for reaching out with your Power BI calculation question. You can follow these steps:

 

  1. Create a measure, calculates the total hours worked for all customers over the 13-month period.

 

Total Hours =
SUM ( Table[HoursWorked] )

 

  1. Create a measure that identifies the top 10 customers based on the total hours worked over the 13-month period.

 

Top 10 Customers =
VAR TopCustomers =
    TOPN ( 10, ALL ( Table[Customer] ), [Total Hours], DESC )
RETURN
    CALCULATE ( [Total Hours], TopCustomers )

 

  1. Create a measure to calculate the total hours worked by the top 10 customers for each month displayed in the matrix.

 

Monthly Hours for Top 10 =
CALCULATE (
    [Total Hours],
    FILTER (
        ALL ( 'Calendar' ),
        'Calendar'[Date] >= MIN ( 'Calendar'[Date] )
            && 'Calendar'[Date] <= MAX ( 'Calendar'[Date] )
    ),
    Table[Customer] IN VALUES ( 'Top 10 Customers'[Customer] )
)

 

  1. Create a measure to calculate the percentage of hours worked by the top 10 customers for each month.

 

Percentage of Hours for Top 10 =
DIVIDE ( [Monthly Hours for Top 10], [Total Hours], 0 )

 

How to Get Your Question Answered Quickly - Microsoft Fabric Community

Thank you for your questions and support. If it does not help, please provide more details with your desired out put and pbix file without privacy information.

 

Best Regards,

Yifan Wang

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

Hi thanks for your reply, 

Monthly Hours for Top 10 =
CALCULATE (
    [Total Hours],
    FILTER (
        ALL ( 'Calendar' ),
        'Calendar'[Date] >= MIN ( 'Calendar'[Date] )
            && 'Calendar'[Date] <= MAX ( 'Calendar'[Date] )
    ),
    Table[Customer] IN VALUES ( 'Top 10 Customers'[Customer] )
)



Part 3 does not work yet.  Within the IN VALUES formula you refer to a table, but in step 3 we create a measure, the formula expects a table. So I cannot use this...

Is there another way?

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.