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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
xariet
Helper I
Helper I

Comparing all sub-category sales to the selected sub-category

I wonder if it's possible to do in power bi. I need to make a bar chart which will show the difference between the selected sub-category and all other categories. 

SUM Sales for Selected Value = CALCULATE(SUM(Orders[Sales]), ALLSELECTED(Orders[Sub-Category]))
Difference from selected Category = SUM(Orders[Sales])-[SUM Sales for Selected Value] doesn't work. It just shows the selected sub-category and the 0 difference. How do I get to show all other sub-categories and their difference values as well?

xariet_0-1674113616620.png

 

xariet_1-1674114192258.png

 

 

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@xariet , FOr this better you create a slicer on an independent Sub Category Table

 

M1= CALCULATE(SUM(Orders[Sales]),Filter( Orders,  Orders[Sub-Category] in values(Orders[Sub-Category])) )

 

Diff = SUM(Orders[Sales])  - [M1]

 

Need of an Independent Table in Power BI - Exclude: https://youtu.be/lOEW-YUrAbE

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

2 REPLIES 2
amitchandak
Super User
Super User

@xariet , FOr this better you create a slicer on an independent Sub Category Table

 

M1= CALCULATE(SUM(Orders[Sales]),Filter( Orders,  Orders[Sub-Category] in values(Orders[Sub-Category])) )

 

Diff = SUM(Orders[Sales])  - [M1]

 

Need of an Independent Table in Power BI - Exclude: https://youtu.be/lOEW-YUrAbE

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

thank you @amitchandak  for your help. your video helped me to understand the solution. I have created a new Orders table and brought sub-category slicer from the new orders table. And then my difference was just the difference in Sales from the ols and new tables. I didn't have to use M1  measure.

Diff = SUM(Orders[Sales])  - [Sum Sales New Table]
xariet_0-1674429925295.png

 

 

 

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.