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
Marico
Helper IV
Helper IV

Combined Matrix

Hi - My sample data looks like the following:

 

SalesInternal/ ExternalCategoryFlag
10InternalCat1Flag 1
20ExternalCat1Flag 1
30InternalCat2Flag 1
40ExternalCat2Flag 1
50InternalCat1Flag 2
60ExternalCat1Flag 2
70InternalCat2Flag 2
80ExternalCat2Flag 2

 

I want to create a combined table like below based on the following two sub tables:

 

CategoryFlag 1Flag 2
InternalExternalInternalExternal
Cat110205060
Cat230407080

 

CategoryTotal no. of sales
InternalExternal
Cat16080
Cat2100120

 

Final output table needed:

 

CategoryTotal no. of salesFlag 1Flag 2
InternalExternalInternalExternalInternalExternal
Cat1608010205060
Cat210012030407080
1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Marico ,

 

The following virtual table can be created with the help of the NATURALINNERJOIN function:

FlagTable = 
SUMMARIZE(
    'SalesData',
    'SalesData'[Category],
    'SalesData'[Flag],
    'SalesData'[Internal/ External],
    "SalesAmount", SUM('SalesData'[Sales])
)

vkongfanfmsft_1-1730106260540.png

TotalSalesTable = 
SUMMARIZE(
    'SalesData',
    'SalesData'[Category],
    'SalesData'[Internal/ External],
    "TotalSales", SUM('SalesData'[Sales])
)

vkongfanfmsft_2-1730106282089.png

FinalOutputTable = 
NATURALINNERJOIN(
    SUMMARIZE(
        'SalesData',
        'SalesData'[Category],
        'SalesData'[Internal/ External],
        "TotalSales", SUM('SalesData'[Sales])
    ),
    SUMMARIZE(
        'SalesData',
        'SalesData'[Category],
        'SalesData'[Flag],
        'SalesData'[Internal/ External],
        "FlagSales", SUM('SalesData'[Sales])
    )
)

vkongfanfmsft_3-1730106301148.png

 

vkongfanfmsft_0-1730106176328.png

 

Best Regards,
Adamk Kong

 

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

7 REPLIES 7
Anonymous
Not applicable

Hi @Marico ,

 

The following virtual table can be created with the help of the NATURALINNERJOIN function:

FlagTable = 
SUMMARIZE(
    'SalesData',
    'SalesData'[Category],
    'SalesData'[Flag],
    'SalesData'[Internal/ External],
    "SalesAmount", SUM('SalesData'[Sales])
)

vkongfanfmsft_1-1730106260540.png

TotalSalesTable = 
SUMMARIZE(
    'SalesData',
    'SalesData'[Category],
    'SalesData'[Internal/ External],
    "TotalSales", SUM('SalesData'[Sales])
)

vkongfanfmsft_2-1730106282089.png

FinalOutputTable = 
NATURALINNERJOIN(
    SUMMARIZE(
        'SalesData',
        'SalesData'[Category],
        'SalesData'[Internal/ External],
        "TotalSales", SUM('SalesData'[Sales])
    ),
    SUMMARIZE(
        'SalesData',
        'SalesData'[Category],
        'SalesData'[Flag],
        'SalesData'[Internal/ External],
        "FlagSales", SUM('SalesData'[Sales])
    )
)

vkongfanfmsft_3-1730106301148.png

 

vkongfanfmsft_0-1730106176328.png

 

Best Regards,
Adamk Kong

 

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

 

Ashish_Mathur
Super User
Super User

Hi,

Your data tables has not been pasted properly in your original post - only the first one is clear.  


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
Marico
Helper IV
Helper IV

 Hi @dharmendars007 - Sorry, I am new to Power BI, all these calculations so would be created through a "New Table measure"? Alos, can't we directly create the final table using summarize?

dharmendars007
Super User
Super User

Hello @Marico , 

 

Step1  -You will need to calculate the total sales grouped by Category and Internal/ExternaL.

 

dharmendars007_0-1728309988267.png

 

Step 2 - Create a Masure for both Flag1 and Flag2

 

dharmendars007_1-1728310091383.png

 

dharmendars007_2-1728310110073.png

 

Step3 = Create a final Table using summarize then use the same to plot in the table visual like you wish in output

 

dharmendars007_3-1728310182356.png

 

If you find this helpful , please mark it as solution which will be helpful for others and Your Kudos/Likes 👍 are much appreciated!

 

Thank You

Dharmendar S

LinkedIN 

 

 

@dharmendars007 I am not able to create the matrix like the below from output of summarize table:

 

Marico_0-1728318015019.png

Could you please share a sample file? Thanks a lot in advance.

Your desired output doesn't seem to make sense. What would you change on the below (which was done without coding)

 

lbendlin_0-1728330127854.png

 

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.