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

The Power BI Data Visualization World Championships is back! It's time to submit your entry. Live now!

Reply
sanjaymithran
Helper II
Helper II

Matrix table with two rows diffrent Aggregation

Hi All,

Thanks in Advance, Below matrix table Category and Product on rows values sales and % sales show values vertically 

Need help on calculation for % sales prod1 35/159(total of all prod within cat1) etc

when in toal % sales 159/402(total of all category) etc

CategoryProductMeasures
Cat1Prod1Sales35
% Sales22%
Prod2Sales48
% Sales30%
Prod3Sales76
% Sales48%
TotalSales159
% Sales40%
Cat2Prod4Sales84
% Sales35%
Prod5Sales53
% Sales22%
TotalSales243
% Sales60%
TotalSales402
% Sales100%

Thanks,

Sanjay

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi, @sanjaymithran 

I'm sorry I misunderstood what you meant, I modified the measure and you can use the DAX below:

%Sale = 
VAR _Total = DIVIDE(
    CALCULATE(SUM([Sales]), ALLEXCEPT('Table', 'Table'[Category])),
    CALCULATE(SUM([Sales]), ALL('Table')),
    0
)
VAR _Category = DIVIDE(
    SUM([Sales]),
    CALCULATE(SUM([Sales]), ALLEXCEPT('Table', 'Table'[Category])),
    0
)
RETURN
IF(ISINSCOPE('Table'[Product]),_Category,_Total)

 

The following is my preview:

vyohuamsft_0-1727335706817.png

 

How to Get Your Question Answered Quickly

Best Regards

Yongkang Hua

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

Hi, @sanjaymithran 

Based on your information, I create a sample table:

vyohuamsft_0-1727314733712.png

 

Then create measures, try the following dax:

% Sales within Category = 
DIVIDE(
    SUM([Sales]),
    CALCULATE(SUM([Sales]), ALLEXCEPT('Table', 'Table'[Category])),
    0
)
% Sales of Total = 
DIVIDE(
    CALCULATE(SUM([Sales]), ALLEXCEPT('Table', 'Table'[Category])),
    CALCULATE(SUM([Sales]), ALL('Table')),
    0
)

 

Put fields in matrix visual, here is my preview:

vyohuamsft_1-1727314960253.png

 

How to Get Your Question Answered Quickly

Best Regards

Yongkang Hua

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

Hi Yongkang Hua,

Thanks for your quick response,I already did like that only but user want single field % Sales.

Product level % Sales within Category and Category level % Sales of Total in Single field because we have many % fields so if we use two for each table too height ,is it possible in single field?

 

Thanks,

Sanjay.

Anonymous
Not applicable

Hi, @sanjaymithran 

I'm sorry I misunderstood what you meant, I modified the measure and you can use the DAX below:

%Sale = 
VAR _Total = DIVIDE(
    CALCULATE(SUM([Sales]), ALLEXCEPT('Table', 'Table'[Category])),
    CALCULATE(SUM([Sales]), ALL('Table')),
    0
)
VAR _Category = DIVIDE(
    SUM([Sales]),
    CALCULATE(SUM([Sales]), ALLEXCEPT('Table', 'Table'[Category])),
    0
)
RETURN
IF(ISINSCOPE('Table'[Product]),_Category,_Total)

 

The following is my preview:

vyohuamsft_0-1727335706817.png

 

How to Get Your Question Answered Quickly

Best Regards

Yongkang Hua

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

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! It's time to submit your entry.

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 Power BI update to learn about new features.

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.