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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
UpharTandon
Frequent Visitor

Two Grand Totals in Matrix Visual based on some conditions

Hi All,

 

I am trying two create a simple matrix visual where I would like to show two grand totals at the end of the matrix.

 

The first grand total (total) is the overall sum of all the rows and another would be the sum based on some conditions, In the below data first total is the overall total, and the second total is where the quantity is 100

 

FYI - This is just sample data I am looking to apply this logic in a big matrix where I have to calculate the total based on certain values (sum where value is 1 or 2).

 

I have tried several ways but unable to achieve it. Anyone, please help me with this.

 

Data and expected output:

 

PersonSalary
100
B200
C400
D100
E100
Total900
Total(100)200

 

Your quick support will be highly appreciated.

 

Regards

Uphar

 

12 REPLIES 12
sebouier
Frequent Visitor

Please try this trick:

First, add a blank left calculated column in matrix visual. You'll get one subtotal row and one total row.

 

Then, change your measure:

 

Measure with subtotal =
    IF(ISINSCOPE([Your blank calulated column],
        CALCULATE(SUM([Your measure]),[Quantity]=100),
        IF(HASONEVALUE([Person]),
            [Your measure],
            CALCULATE(SUM([Your measure]))
        )
    )

 

 

You'll have to rename the (sub)total titles

Hi @sebouier , The above-given solution will work only on one column condition but I have more than one column in filter context. For example, see the below data where I have calculated the total as well as total(flag=1).

 

MonthNameAgeDepartmentSalaryBonusovertimeFlag
MarchABC12HR10050200
MarchABD13QA20060301
MarchDEF14HR30070400
MarchGHI15QA40080501
MarchLMN16HR50090600
AprilGHI17QA600100701
AprilHIJ18HR700110800
AprilKLM19QA800120901
AprilDEF20HR9001301001
   Total4500810540 
   Total(Flag=1)2900490340 

Sorry, I don't know any solutions if you have multiple left columns. 

 

I don't know if it's acceptable for your project but I'd probably use card visual to customize your total, to make it look like it belongs to the table visual.

I'd put it at the top of the table. Then you don't have to care about the size of your table.

sebouier_0-1673618020477.png

 

tamerj1
Super User
Super User

Hi @UpharTandon 
Perhaps something like this? See attached sample file

1.png2.png3.png

Just to provide more context in the below data I am summing up all the rows where flag ='1'.

 

PersonSalaryFlaglast year salary
100180
B2000180
C4000400
D100190
E100180
Total9000830
Total(100)300 250

 

Similarly, I have many column to I would like to sum up based on the flag condition. 

Hi Temerj, I don't want to create any additional rows in the table (total(100)). Just wanted to show this at the last in the matrix the same way the total column is showing in the above snapshot you had given.

@UpharTandon 
This is just a workaround as there no option is PowerBi (up to my knowlage) to have more than one grand total in a table or matrix. 
Another worrkaround using a matrix visual as follows

2.png1.png

Hi @tamerj1 , I tried your solution but it is not working when we have more than one filter context in the table, and the matrix shows repetitive values. 

 

UpharTandon_1-1673526546026.png

Below is the query I have written

Total Salary =
IF (
    SELECTEDVALUE ('Table'[Book Month] ) = "Total(SAS)",
    CALCULATE ( SUM(VW_U_RECAP[Total SQC Awarded excluding UMS]),
    VW_U_RECAP[Saas new unit] = 1,
        ALL ( VW_U_RECAP)
    ),
    SUM(VW_U_RECAP[Total SQC Awarded excluding UMS])
)

 

 

Do you have any other idea?

@UpharTandon 
Can you provide sample data or sample file to work with?

Hi @tamerj1 , Thank you for sharing this but the only issue with my dataset is I will not be able to create any supportive table in the BI model as there are multiple categories available and against them we have flag ='1' to a particular date. 

FreemanZ
Super User
Super User

Hi @UpharTandon 

what columns and rows do you have in your matrix visual?

 

you can also try to create two card visuals with two measures like this:

 

AllTotal =
CALCULATE(SUM(TableName[Salary]), ALL(TableName))

100Total
CALCULATE(SUM(TableName[Salary]), TableName[Salary]=100)

 

Hi, I don't want to use card visuals as business requirement is to show everything on the matrix. Apart from this I have approx 30 columns in matrix.

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors