Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin 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.
Hi,
I'm trying to achieve the following in BI:
I have sales split by category: Meat, Fish, Vegetables
I want to calculate a category as a percentage of total sales.
How do I prevent the Total Sales value being filtered when I filter a category using a slicer? eg Meat Sales/Total Sales.
Hope somebody can point me in the right direction?
Hi, @Chalklands
Based on your description, I created data to reproduce your scenario.
You can create a measure as follows.
Percentage Of Total Sales = DIVIDE(
SUM('Table'[Sales]),
CALCULATE(SUM('Table'[Sales]),ALL('Table'))
)
Result:
If I misunderstand your thought, please show me your sample data and expected output. I am glad to solve the problem for you.
Best Regards,
Allan
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Thank you for your help.
I've replicated your data and it works fine. However in my live report I also have my data potentially filtered by other factors (year, month etc). How would I rewrite the formula to take into account? Is this possible to do?
eg Meat sales as % of total sales in 2019 or 2018 (depending on which year is selected)?
Thanks in advance!
Hi, @Chalklands
Here is my sample data.
Table:
ReportDates:
You can create a measure as follows.
Percentage of Total Sales =
DIVIDE(
SUM('Table'[Sales]),
CALCULATE(
SUM('Table'[Sales]),
ALLSELECTED('Table')
)
Result:
Best Regards
Allan
Hi Allan,
Thanks for your reply. I think my problem is that I data in different tables eg Dates, Product Details, Sales data. I can't work out how to get the measure to work if different elements are in different tables. ~Here is a screen shot of the data model:
And a link to the pbix file:
Regards
Pete
Hi, @Chalklands
You can change the measure as follows.
Total Sales =
CALCULATE(
SUM('Sales Data'[Qty invoiced]),
ALL('Category Icons'),ALL(vw_PowerBI_ProductList),ALL('Sales Data'),'Dates'
)
Result:
Best Regards
Allan
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
HI
You need to use calculate(sum(x), All(table)) will allow the calculation to happen without filtering the calculation:
If I answer your question, please mark my post as a solution, this will also help others.
Please give Kudos for support.
Tomas Santandreu Polanco |Principal Business Intelligence Consultant
www.designmind.com
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
77 | |
76 | |
57 | |
36 | |
34 |
User | Count |
---|---|
99 | |
56 | |
56 | |
46 | |
40 |