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
Anonymous
Not applicable

Calculate % of filtered rows in column

Scenario:
I have a matrix with the type of time entry various staff make against various time codes.
I want to calculate the % of time entered in, say, Time Codes 2 and 3
Example: 

                      Alex    Bob  Chi   Dave
Time Code 1   1        1      3        
Time Code 2   2        1              3
Time Code 3             2      2      1
Time Code 4  1         1      3      2
Time Code 5  2         2              2
TOTAL            6        6      8       8
% of TC 2/3   33%   50% 25% 50%

 

Note that this Matrix is already a summary of time entered acorss a variable date field, so an an entry is already summing entries to that time code for the filtered date range.
I have NO IDEA how to even begin doing this!

HEELP!


Thanks!

 

1 ACCEPTED SOLUTION

Hi @Anonymous ,

 

 You need convert the format of Hour to whole number, and then use the measures:

 

Measure = CALCULATE(SUM('Table'[Hour]),ALLEXCEPT('Table','Table'[Code],'Table'[Name]))
Measure 2 = CALCULATE(SUM('Table'[Hour]),FILTER(ALL('Table'),[Code]="TC 2"||[Code]="TC 3"),VALUES('Table'[Name]))
Measure 3 = CALCULATE(DIVIDE([Measure 2],[Measure]),ALLEXCEPT('Table','Table'[Name]))

2.PNG

 

Community Support Team _ Dina Ye
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

3 REPLIES 3
v-diye-msft
Community Support
Community Support

Hi @Anonymous ,

 

You can add the calculated column:

Total = [Time Code 1]+[Time Code 2]+[Time Code 3]+[Time Code 4]+[Time Code 5]
% of TC 2/3 = DIVIDE([Time Code 2]+[Time Code 3],[Total])

Then put it on values:

06.PNG

Pbix attached.

Community Support Team _ Dina Ye
If this post helps, then please consider Accept it as the solution to help the other members find it more
quickly.
Anonymous
Not applicable

Thank you, I appreciate your help in this.
Unfortunately, my data is laid out differntly, and I apologise for not being mor clear.

The underlying data table looks like this:

Name       Code      Hours
Alex         TC 1       1
Alex         TC 2       1
Alex         TC 5       1
Alex         TC 4       1
Alex         TC 2       1
Alex         TC 1       1
Alex         TC 2       1
Alex         TC 5       1
Bob         TC 1       1
Bob         TC 2       1  

etc....

So I can't add the TC values as they are type string.

 

Thanks!

Hi @Anonymous ,

 

 You need convert the format of Hour to whole number, and then use the measures:

 

Measure = CALCULATE(SUM('Table'[Hour]),ALLEXCEPT('Table','Table'[Code],'Table'[Name]))
Measure 2 = CALCULATE(SUM('Table'[Hour]),FILTER(ALL('Table'),[Code]="TC 2"||[Code]="TC 3"),VALUES('Table'[Name]))
Measure 3 = CALCULATE(DIVIDE([Measure 2],[Measure]),ALLEXCEPT('Table','Table'[Name]))

2.PNG

 

Community Support Team _ Dina Ye
If this post helps, then please consider Accept it as the solution to help the other members find it more
quickly.

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.