The above video walks you through how to set up a stacked bar chart to show 1 (or more) categories against the rest of the categories in Power BI with DAX. This is a bit difficult to explain without an example, so here’s a gif showing the finished product:

Here’s the final DAX code necessary to set this up:

Sales vs Others = 
VAR CurrentCategory = MAX('Categories + Other'[Category Name])
VAR CurrentCategoryStacked = MAX('Categories + Other (Stacked)'[Category Name])
VAR SelectedCategories = ALLSELECTED(Categories[Category Name])
VAR PossibleCategories = ALL(Categories[Category Name])
RETURN
SWITCH(
   TRUE(),
   CurrentCategory IN SelectedCategories && CurrentCategoryStacked = CurrentCategory, 
   CALCULATE(
      [Total Sales],
      Categories[Category Name] = CurrentCategory
   ),
   CurrentCategory = "Others", 
   CALCULATE(
      [Total Sales], 
      FILTER(
         ALL(Categories[Category Name]),
         Categories[Category Name] IN PossibleCategories
         && NOT(Categories[Category Name] IN SelectedCategories)
         && Categories[Category Name] = CurrentCategoryStacked
      )
   )
)

I hope you enjoyed learning this advanced trick! If you would like to access the data behind this report, make sure to check out my Training courses here. All memberships grant you access to a live SQL Server database to practice Power BI!


Parker Stevens

Parker is the creator of the BI Elite YouTube channel, a community of over 30,000 students learning Power BI, DAX, and Power Query. He is a Microsoft Data Platform MVP for his work with Power BI and continues to provide elite Power Platform training courses to help data analysts, BI developers, and citizen dashboard creators reach their goals. Parker is committed to producing high-quality training content that is also extremely cost-effective, to ensure that the largest amount of users can benefit from the content. Training courses located at https://training.bielite.com/