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
StevenT
Helper V
Helper V

Want my chart to show total of all in table or the item clicked on

Hi I have a matrix and I have a bar chart.
When I click on one or more items in the matrix i want the chart to show each clicked item individually.
if I don't click on an item i want one line that shows total in chart.

I've used copilot and other help tools but can't find a solution.
Any help is appreciated....

--Steven

1 ACCEPTED SOLUTION
v-hashadapu
Community Support
Community Support

Hi @StevenT , Thank you for reaching out to the Microsoft Community Forum.

 

The answer shared by @kushanNa  seems appropriate. Can you please confirm if the solution worked for you. It will help others with similar issues find the answer easily.
Thank you.

View solution in original post

6 REPLIES 6
v-hashadapu
Community Support
Community Support

Hi @StevenT , Hope you're doing okay! May we know if it worked for you, or are you still experiencing difficulties? Let us know — your feedback can really help others in the same situation.

v-hashadapu
Community Support
Community Support

Hi @StevenT , Thank you for reaching out to the Microsoft Community Forum.

 

The answer shared by @kushanNa  seems appropriate. Can you please confirm if the solution worked for you. It will help others with similar issues find the answer easily.
Thank you.

kushanNa
Super User
Super User

Hi @StevenT 

 

Are you looking for an output similar to this ? 

 

kushanNa_0-1754237963220.pngkushanNa_1-1754237993133.png

If this is what you need please follow the following steps 

 

Step 1: Create a new support Table

 

Table B = 
UNION(
    DISTINCT(SELECTCOLUMNS('Table A', "Product", 'Table A'[Product])),
    ROW("Product", "All")
)

 

Step 2: Create Relationship

 

Go to Model view and create a relationship:

  • From: Table A[Product]
  • To: Table B[Product]
  • Cardinality: Many to one (Table A → Table B)

Make sure this relationship is active.

 

Step 3: Create Measures

Sales Measure (Total or Filtered)

This measure checks the selected product. If "All" is selected, it returns total sales. If a specific product is selected, it filters accordingly.

 

Sales Measure = 
VAR CurrentProduct = SELECTEDVALUE('Table B'[Product])
RETURN
    IF(
        CurrentProduct = "All",
        CALCULATE(
            SUM('Table A'[Sales]),
            ALLEXCEPT('Table A', 'Table A'[Region])  
        ),
        CALCULATE(
            SUM('Table A'[Sales]),
            'Table A'[Product] = CurrentProduct
        )
    )

Selection Flag (For Visual Filter)

This measure ensures the correct rows appear in your visuals:

 

Selection Flag product = 
IF(
    ISFILTERED('Table A'[Product]),
    IF(
        SELECTEDVALUE('Table B'[Product]) = SELECTEDVALUE('Table A'[Product]),
        1,
        0
    ),
    IF(
        SELECTEDVALUE('Table B'[Product]) = "All",
        1,
        0
    )
)

Step 4: Create the Stacked Bar Chart

  1. Insert a stacked bar chart
  2. Create a Matrix table with Table A Columns Product, Region, Sales  
  3. Set up the fields:
    • Y-axis → 'Table B'[Product]
    • X-axis (Values) → Sales Measure
    • Legend → 'Table A'[Region]

Step 5: Apply Visual-Level Filter

To make sure only the selected product (or total) is shown:

  1. Select the chart.
  2. Drag the Selection Flag product measure to the Visual-level filters pane.
  3. Set the filter to "is 1".

Edit Interactions

 

  1. Select the matrix table .
  2. Go to Format > Edit Interactions
  3. For each visual:
    • Choose Filter kushanNa_2-1754238246717.png

 

That should be it , and it should work 

 

I have attached the sample pbix file for your reference 

 

 

 

 

That worked great! Thank you!

DataVitalizer
Solution Sage
Solution Sage

Hi @StevenT 


What you want is doable by using a measure that changes based on what’s selected in your matrix.


Try creating a measure like this for your bar chart:


Chart Value =
IF(
ISFILTERED('YourTable'[YourColumn]),
SUM('YourTable'[Value]),
CALCULATE(SUM('YourTable'[Value]), ALL('YourTable'[YourColumn]))
)

 

Just replace 'YourTable'[YourColumn] with the field you use in the matrix and 'YourTable'[Value] with the numbers that you want summed together.

 

Also make sure that the visuals are set to filter each other.

 

Did it work? 👍 A kudos would be appreciated
🟨 Mark it as a solution to help spread knowledge 💡

 

🟩 Follow me on LinkedIn

Thanks for this suggestion. Unfortunately in my matrix, if I unclick all selections in the matrix, the line chart shows everything as a separate line.
Ultimately I want to be able to show the grand total when nothing is clicked in the matrix.

What I did with your measure is replace the sales with your measure, and I basically got the same thing that I would have if I just left sales there. 

Maybe there's more to it than just the measure?

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!

November Power BI Update Carousel

Power BI Monthly Update - November 2025

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