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
Chalklands
Helper I
Helper I

Divide filtered value by unfiltered value

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?

6 REPLIES 6
v-alq-msft
Community Support
Community Support

Hi, @Chalklands 

Based on your description, I created data to reproduce your scenario.

a1.png

You can create a measure as follows.

Percentage Of Total Sales = DIVIDE(

    SUM('Table'[Sales]),

    CALCULATE(SUM('Table'[Sales]),ALL('Table'))

)

Result:

a2.png

a3.png

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:

x1.png

ReportDates:
x2.png

 

You can create a measure as follows.

Percentage of Total Sales = 
                            DIVIDE(
                                   SUM('Table'[Sales]),
                                   CALCULATE(
                                       SUM('Table'[Sales]),
                                       ALLSELECTED('Table')
                            )

 

Result:

x3.png

 

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:

 

Capture.GIF

 

And a link to the pbix file:

category.pbix 

 

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:

b1.png

 

Best Regards

Allan

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Anonymous
Not applicable

HI

 

You need to use calculate(sum(x), All(table)) will allow the calculation to happen without filtering the calculation:

https://dax.guide/calculate/

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

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.