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

The ultimate Microsoft Fabric, Power BI, Azure AI & SQL learning event! Join us in Las Vegas from March 26-28, 2024. Use code MSCUST for a $100 discount. Register Now

Regular Visitor

Calculate total of uncategorised data for stacked column chart


I am wanting to display data broken down by category on a stacked column chart. However the data is for the categories and the overall total, but the sum of all the categories is less than the total (meaning there is some uncategorised data). So I can only get the column chart to either show the overall total (with no breakdown per category), or the sum of the categories (but this is not the overall total).


This is different to typical examples I have seen where the total is simply aggregated from the relevant categories.


For example; Table 1 (which has the data from the devices) is linked to Table 2 which shows which devices are for which category and which are for the overall total.


Device NumberValue
Device 110
Device 220
Device 330
Device 440
Device 550
Device 660

Table 1


Device NumberCategoryTotal
Device 1A 
Device 2A 
Device 3B 
Device 4B 
Device 5 Yes
Device 6 Yes

Table 2


Category A total is 30 (Device 1 + Device 2), category B total is 70 (Device 3 + Device 4), and the overall total is 110 (Device 5 + Device 6). Is it possible for Power BI to calculate the value of the uncategorised data from the overall total minus the sum of all the categories [110 - (30 + 70)], so the stacked column chart shows the breakdown by category and the correct overall total? If so, what is the best way of doing this?


Regular Visitor

@amitchandak Thank you so much for your help. With a few modifications I can now get the correct stacked column chart for the example data. The formula I used is:

Measure =

MAX(Table2[Category]) = "Uncategorised", CALCULATE( SUM(Table1[Value]), Table2[Category] = BLANK() ) - CALCULATE( SUM(Table1[Value]), Table2[Category] <> BLANK() ),
SUM(Table1[Value]) )
Correct Output.PNG

However, for the real data there can be instances where a device is in a category and the overall total. So will need to refer to the Total column in table 2 rather than relying on the Category column being blank. However, when I update the measure to use the Total column, I get the wrong output. Do you know how to resolve this?


Measure =
MAX(Table2[Category]) = "Uncategorised", CALCULATE( SUM(Table1[Value]), Table2[Total] = "Yes" ) - CALCULATE( SUM(Table1[Value]), Table2[Category] <> BLANK() ),
SUM(Table1[Value]) )

 Incorrect Output.PNG



Super User
Super User

@martos360 , In Power query replace null(all small) with Uncategorised or empty string with Uncategorised.


Join the two tables in Device number


Then you can have a one the following meausre


Measure =

Switch( True(),

max(Table[Category]) = "Uncategorised", calculate( sum(Table1[Sum]), Table2[Category] = "Uncategorised")- calculate( sum(Table1[Sum]), Table2[Category] <> "Uncategorised"),

sum(Table1[Sum]) )


Measure =
Switch( True(),
max(Table[Category]) = "Uncategorised",
calculate( sum(Table1[Sum]),filter(all(Table2), Table2[Category] = "Uncategorised"))- calculate( sum(Table1[Sum]),filter(all(Table2), Table2[Category] <> "Uncategorised")),


Helpful resources

Fabric Community Conference

Microsoft Fabric Community Conference

Join us at our first-ever Microsoft Fabric Community Conference, March 26-28, 2024 in Las Vegas with 100+ sessions by community experts and Microsoft engineering.

February 2024 Update Carousel

Power BI Monthly Update - February 2024

Check out the February 2024 Power BI update to learn about new features.

Fabric Career Hub

Microsoft Fabric Career Hub

Explore career paths and learn resources in Fabric.

Fabric Partner Community

Microsoft Fabric Partner Community

Engage with the Fabric engineering team, hear of product updates, business opportunities, and resources in the Fabric Partner Community.

Top Solution Authors