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
gaLaii
Regular Visitor

Sum of Average of each subcategory in Visual Table

Hi

 

I have a table with  categories and subcategories. i want to display i power BI visual table the average of the subcategories but display the sum of the average subcategories  per category. here is the sample result and sample table source below. 

 

Sample Table 

DateCategorySub-CategoryScore
10-JanCategory 1Sub-Category 11
10-JanCategory 1Sub-Category 25
10-JanCategory 1Sub-Category 35
10-JanCategory 1Sub-Category 45
10-JanCategory 1Sub-Category 54
10-JanCategory 1Sub-Category 65
10-JanCategory 2Sub-Category 15
10-JanCategory 2Sub-Category 22
10-JanCategory 2Sub-Category 31
10-JanCategory 2Sub-Category 42
10-JanCategory 3Sub-Category 15
10-JanCategory 3Sub-Category 21
10-JanCategory 4Sub-Category 14
10-JanCategory 4Sub-Category 22
10-JanCategory 4Sub-Category 34
10-JanCategory 4Sub-Category 45
10-JanCategory 4Sub-Category 52
11-JanCategory 1Sub-Category 15
11-JanCategory 1Sub-Category 24
11-JanCategory 1Sub-Category 33
11-JanCategory 1Sub-Category 45
11-JanCategory 1Sub-Category 54
11-JanCategory 1Sub-Category 62
11-JanCategory 2Sub-Category 14
11-JanCategory 2Sub-Category 21
11-JanCategory 2Sub-Category 32
11-JanCategory 2Sub-Category 43
11-JanCategory 3Sub-Category 15
11-JanCategory 3Sub-Category 25
11-JanCategory 4Sub-Category 11
11-JanCategory 4Sub-Category 25
11-JanCategory 4Sub-Category 34
11-JanCategory 4Sub-Category 44
11-JanCategory 4Sub-Category 55

 

Desired Result in power bi

gaLaii_0-1674838107836.png

 

 

 

 

 

 

 

 

 

 

1 ACCEPTED SOLUTION
v-rzhou-msft
Community Support
Community Support

Hi @gaLaii ,

 

With amitchandak's measure, you will get correct result in subtotal, however incorrect in Total.

RicoZhou_0-1675071892367.png

You can try my code to create a measure.

Sum of Avg =
VAR _SUMMARIZE =
    SUMMARIZE (
        'Table',
        'Table'[Category],
        'Table'[Sub-Category],
        "Avg", AVERAGE ( 'Table'[Score] )
    )
RETURN
    SUMX ( _SUMMARIZE, [Avg] )

Result is as below.

RicoZhou_1-1675071934267.png

 

Best Regards,
Rico Zhou

 

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-rzhou-msft
Community Support
Community Support

Hi @gaLaii ,

 

With amitchandak's measure, you will get correct result in subtotal, however incorrect in Total.

RicoZhou_0-1675071892367.png

You can try my code to create a measure.

Sum of Avg =
VAR _SUMMARIZE =
    SUMMARIZE (
        'Table',
        'Table'[Category],
        'Table'[Sub-Category],
        "Avg", AVERAGE ( 'Table'[Score] )
    )
RETURN
    SUMX ( _SUMMARIZE, [Avg] )

Result is as below.

RicoZhou_1-1675071934267.png

 

Best Regards,
Rico Zhou

 

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

Thank you so much.. Appreciate it!!!

amitchandak
Super User
Super User

@gaLaii , Try a measure like

Sumx(Values(Table[Sub Category]), calculate(Average(Table[Score]) ) )

 

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.

Top Solution Authors