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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
sneidercub
Frequent Visitor

Array to display the total category group

Hello Community,

So I have this database with about 2 million rows structured like that.


Category.png

So what I want to do is show them in a matrix like this.

Category Result.png

I was trying to add the word "Total" as another category and calculate the values with a new measure.
This in order to add that new measure as the "Values" for the matrix, but I still did not get any success.


Could you help me with some ideas so I can do it?

1 ACCEPTED SOLUTION

Hi @sneidercub ,

I've updated the Sum with Total measure to:

 

Sum with Total = 
VAR __One =
    SELECTEDVALUE ( Category[Category] )
RETURN
    IF (
        __One = "Total"
            || NOT ( HASONEVALUE ( Category[Category] ) ),
        CALCULATE ( SUM ( 'Table'[Value] ), ALL ( 'Table'[Category] ) ),
        CALCULATE (
            SUM ( 'Table'[Value] ),
            FILTER ( 'Table', 'Table'[Category] = __One )
        )
    )

 

 

The rest involves formatting the matrix visual. However, selectively removing the subtotal for each item in a column is not currently supported.

danextian_0-1653534042970.png

You may refer to the same link for the updated pbix.

 





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

Did I answer your question? Mark my post as a solution!


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

View solution in original post

6 REPLIES 6
danextian
Super User
Super User

Hi @sneidercub ,

My approach would be to create a disconnected table (no relationship with other tables) and use that to hold the values needed.

 

Calculated table:

Category = 
VAR __T1 =
    DISTINCT ( 'Table'[Category] )
RETURN
    UNION ( __T1, ROW ( "Category", "Total" ) )

Measure:

Sum with Total = 
VAR __CATEGORY =
    SELECTEDVALUE ( Category[Category] )
RETURN
    IF (
        __CATEGORY = "Total",
        CALCULATE ( SUM ( 'Table'[Value] ), ALL ( 'Table'[Category] ) ),
        CALCULATE (
            SUM ( 'Table'[Value] ),
            FILTER ( 'Table', 'Table'[Category] = __CATEGORY )
        )
    )

Output:

danextian_0-1653526738520.png

Sample PBIX: https://drive.google.com/file/d/1Rnlav71Z0idt6lVRmyI70kjI6JgBLrqe/view?usp=sharing 





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

Did I answer your question? Mark my post as a solution!


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

That's great! 

Thank you for your help!

I think I may have simplified too much the issue, let me try to show a little more about what I'm working on:

so this is a "better" view for the data base:
With year.png
 besides year there are like other 4 or 5 "categories" that I would have to take in consideration, and the final view I want to get should look more like this:

With year solution.png

and taking into consideration it's a 2 million rows database I'm not sure if creating a new disconnected table with a cross join will help.

Could you help me with your approach to this?

Thank you again @danextian 

Please post  a sample data that can be easily copy-pasted.





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

Did I answer your question? Mark my post as a solution!


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

Hi @sneidercub ,

I've updated the Sum with Total measure to:

 

Sum with Total = 
VAR __One =
    SELECTEDVALUE ( Category[Category] )
RETURN
    IF (
        __One = "Total"
            || NOT ( HASONEVALUE ( Category[Category] ) ),
        CALCULATE ( SUM ( 'Table'[Value] ), ALL ( 'Table'[Category] ) ),
        CALCULATE (
            SUM ( 'Table'[Value] ),
            FILTER ( 'Table', 'Table'[Category] = __One )
        )
    )

 

 

The rest involves formatting the matrix visual. However, selectively removing the subtotal for each item in a column is not currently supported.

danextian_0-1653534042970.png

You may refer to the same link for the updated pbix.

 





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

Did I answer your question? Mark my post as a solution!


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

Amazing! That's what I was looking for. Thank you so much! 

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 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.