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
MCG
Helper I
Helper I

Percent within Group

Hi,

i have data set showing sales of product in category:

product  category  sales

a1             a            10

a2             a             20

b1             b            30

b2             b             40

 

how can i calculate measure that will return % of sales within category but i want to have only product list displayed on canvas:

product   share

a1            33% ( as result of 10 for a1 and category total a1+a2=30)

a2            66%

b1           43% (30/ 70)

b2           57%

 

thanks

mcg

 

1 ACCEPTED SOLUTION
kriscoupe
Solution Supplier
Solution Supplier

Awesome @MCG  😀! Would you mind marking the answer as a solution so that other can find this in the future and close the thread as solved?

 

Thanks!

Kris

View solution in original post

5 REPLIES 5
AntrikshSharma
Super User
Super User

Just going one step further, you could try this as well:

% of Total =
VAR ProductSales =
    CALCULATE ( [TotalSales], ALLSELECTED ( Mcg[Product] ) )
VAR CategorySale =
    CALCULATE ( [TotalSales], ALLSELECTED ( Mcg[Category] ) )
VAR Result =
    IF (
        ISINSCOPE ( Mcg[Product] ),
        DIVIDE ( [TotalSales], ProductSales ),
        IF (
            ISINSCOPE ( Mcg[Category] ),
            DIVIDE ( [TotalSales], CategorySale ),
            DIVIDE ( [TotalSales], CALCULATE ( [TotalSales], ALLSELECTED ( Mcg ) ) )
        )
    )
RETURN
    Result

mcg.PNG

Thanks

I will also try your solution

MCG

kriscoupe
Solution Supplier
Solution Supplier

Hi @MCG,

 

You need to use the CALCULATE function to find your sales for all products in that category. This should work.

 

VAR ProductSales = SUM( Sales )

VAR CategorySales =

CALCULATE(

    SUM( Sales ),

    ALL( The table with products in ),

    VALUES( Your category column )

)

RETURN

ProductSales / CategorySales

 

Effectively the ALL/VALUES combination removes the filters on product but then puts them back on for category.

 

Let me know if this helps

 

Kris

This is exactly what i was lookin for:)

great thanks

MCG

kriscoupe
Solution Supplier
Solution Supplier

Awesome @MCG  😀! Would you mind marking the answer as a solution so that other can find this in the future and close the thread as solved?

 

Thanks!

Kris

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!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.