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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Justas4478
Post Prodigy
Post Prodigy

% of total measure

Hi, I have three part measure to calculate % of total.
1st : Total Orders = CALCULATE(COUNT('Order data'[Document]))

2nd : Total Orders Sum =CALCULATE(COUNT('Order data'[Document]),

    ALLEXCEPT('Order data','Order data'[Customer Group],'Order data'[Carrier Hub]))
3rd : 
% of Total Orders = DIVIDE([Total Orders],[Total Orders Sum total])

3rd measure is the one that is used in visuals or tables.
The problem is that on the report page there are some filters that are constantly applied.
Thats the filter applied for Carrier Hub:
Justas4478_0-1753791390627.png

And for Customer group:

Justas4478_1-1753791536398.png

As you see filters exclude some of the choices from reporting, but that was still included in the total orders Sum measure so I had to add this line ALLEXCEPT('Order data','Order data'[Customer Group],'Order data'[Carrier Hub]).
The problem is that while it works for top level number it does not work well when you use Customer group slicer for the user to interact and % become wrong when any slicer option is selected.

I am not sure if I over complicated this measure and there is other solution that targets the page filters.

1 ACCEPTED SOLUTION
v-agajavelly
Community Support
Community Support

Hi @Justas4478 ,

Thanks for the screenshot now it’s crystal clear what you’re looking for. You're applying page-level filters like Carrier Hub and Customer Group, and you want your KPI card to show the percentage relative to the filtered total, not the grand total. Right?

The issue is that DAX by default (especially with ALLSELECTED) often includes more context than you’d expect, so your percentages don’t reflect just the filtered 4313 total shown at the bottom.

You need to remove only the visual-level breakdown (like Region or Product Line), but keep the page/slicer filters intact. The DAX function that does this perfectly is REMOVEFILTERS().

Here’s the formula you can use.

% of Filtered Total =  DIVIDE(COUNTROWS('Order data'),CALCULATE(COUNTROWS('Order data'),REMOVEFILTERS('Order data'[YourBreakdownColumn])))

Replace [YourBreakdownColumn] with the column you’re using to break down the KPI card like Region, Customer Segment, or whatever category is in that card.

If you’re breaking down by Order data[Region], use the bellow formula.

% of Filtered Total = DIVIDE(COUNTROWS('Order data'),CALCULATE(COUNTROWS('Order data'),REMOVEFILTERS('Order data'[Region])))

Now your KPI card will treat the filtered 4313 total as 100%, and each sub-region or item will show the correct percentage of just that total.

Let me know if you need help in it to your exact column name, but this should work as-is once you plug in your breakdown field.

Thanks,
Akhil.

View solution in original post

7 REPLIES 7
v-agajavelly
Community Support
Community Support

Hi @Justas4478 ,

Thanks for the screenshot now it’s crystal clear what you’re looking for. You're applying page-level filters like Carrier Hub and Customer Group, and you want your KPI card to show the percentage relative to the filtered total, not the grand total. Right?

The issue is that DAX by default (especially with ALLSELECTED) often includes more context than you’d expect, so your percentages don’t reflect just the filtered 4313 total shown at the bottom.

You need to remove only the visual-level breakdown (like Region or Product Line), but keep the page/slicer filters intact. The DAX function that does this perfectly is REMOVEFILTERS().

Here’s the formula you can use.

% of Filtered Total =  DIVIDE(COUNTROWS('Order data'),CALCULATE(COUNTROWS('Order data'),REMOVEFILTERS('Order data'[YourBreakdownColumn])))

Replace [YourBreakdownColumn] with the column you’re using to break down the KPI card like Region, Customer Segment, or whatever category is in that card.

If you’re breaking down by Order data[Region], use the bellow formula.

% of Filtered Total = DIVIDE(COUNTROWS('Order data'),CALCULATE(COUNTROWS('Order data'),REMOVEFILTERS('Order data'[Region])))

Now your KPI card will treat the filtered 4313 total as 100%, and each sub-region or item will show the correct percentage of just that total.

Let me know if you need help in it to your exact column name, but this should work as-is once you plug in your breakdown field.

Thanks,
Akhil.

Justas4478
Post Prodigy
Post Prodigy

@v-agajavelly Your solutions work but not in a way that I am trying to archeve. I am trying to use measure in KPI card.

Justas4478_0-1753947872257.png

The total amount of orders before any filters is 5248, after Carrier hub and Customer Group page filters are applied total becomes 4313. 
This is the new total that I am trying to count as 100%, While your solution returns it as 82% which I know is not wrong but it does not works for me, it would work if I would not need to apply any page filters.

v-agajavelly
Community Support
Community Support

Hi @Justas4478 ,

Thanks to @rohit1991  for already pointing in the right direction with ALLSELECTED.

I just wanted to confirm that I tested this approach end-to-end, and this version works as expected, especially when slicers like Customer Group and Carrier Hub are in play.

Try bellow measure,

% of Total Orders = DIVIDE(COUNT('Orderdata'[Document]),CALCULATE(COUNT('Order data'[Document]),ALLSELECTED('Order data')))

If you ever need a fixed % of entire dataset, use bellow measure.

% of Grand Total Orders =DIVIDE(COUNT('Order data'[Document]),CALCULATE(
COUNT('Order data'[Document]),ALL('Order data')))

I’d suggest using ALLSELECTED in your case, since your totals need to respect slicer interaction  and this approach should now give you exactly what you're looking for. Let me know if you'd like a demo PBIX file  to troubleshoot.

Regards,
Akhil.

rohit1991
Super User
Super User

Hi @Justas4478 ,

 

This is a classic DAX headache, and you’re not alone—percent of total measures get tricky with slicers and filters! The trick is to choose the right context for your denominator, and that really depends on what you want your % to represent.

 

For tables and visuals where you want “% of total for what’s visible” (including slicers, page filters, etc.):

 

% of Total Orders =
VAR _TotalOrders = COUNT('Order data'[Document])
VAR _VisibleTotal = CALCULATE(
    COUNT('Order data'[Document]),
    ALLSELECTED('Order data')
)
RETURN DIVIDE(_TotalOrders, _VisibleTotal)

 

If you want a “% of absolute grand total” (ignoring all filters, even slicers):

% of Grand Total Orders =
VAR _TotalOrders = COUNT('Order data'[Document])
VAR _GrandTotal = CALCULATE(
    COUNT('Order data'[Document]),
    ALL('Order data')
)
RETURN DIVIDE(_TotalOrders, _GrandTotal)

 

You’ll often see 100% because the card only shows a single value (its own context). If you want your card to always show % of the grand total, use the second version above (ALL). If you want to show something different on cards than in your tables, you can make a dedicated measure, but often you just need to adjust your denominator logic.


Decide what “total” means to your business question visible total, filtered total, or true grand total and pick your denominator accordingly.


Did it work? ✔ Give a Kudo • Mark as Solution – help others too!
DataNinja777
Super User
Super User

Hi @Justas4478 ,

 

Yes, you've correctly identified the issue, and there's a more direct and robust DAX pattern for this common scenario using the ALLSELECTED function. Your ALLEXCEPT approach fails when a slicer is used because it's designed to keep the filters on the specified columns, including the new filter from the slicer. This causes your denominator to shrink to match your numerator, resulting in an incorrect percentage. The goal is to have a denominator that respects the permanent page filters but ignores the filtering applied by the visual itself.

 

You can replace all three of your measures with this single, more efficient DAX expression. It calculates the numerator and the correct denominator in one go.

% of Total Orders =
VAR _TotalOrders =
    COUNT ( 'Order data'[Document] )
VAR _AllVisibleOrders =
    CALCULATE (
        COUNT ( 'Order data'[Document] ),
        ALLSELECTED ( 'Order data' )
    )
RETURN
    DIVIDE ( _TotalOrders, _AllVisibleOrders )

This measure works by first defining _TotalOrders as the count of orders in the current filter context, which serves as your numerator. The key part is the _AllVisibleOrders variable. Here, CALCULATE modifies the context using ALLSELECTED('Order data'), which removes filters applied by the visual (like the specific group on a table row) but preserves filters coming from slicers and the report page. This correctly calculates the grand total for all data currently visible on the page, creating the perfect denominator.

 

This approach is better because it's correct and works reliably whether you have slicers active or not. It adds simplicity by consolidating three measures into one, making your model cleaner. It's also more robust because using ALLSELECTED on the whole table means you won't need to update the DAX if you add other page filters in the future.

@DataNinja777 I tried your suggestion, it works if I add it to the table it works well percentages are correct and they scale well. how ever if I use it in a KPI card it does not work and it returns 100% all the time regardless of any filters applier.
That makes me think do I have to built separate measure to use for KPI cards only?

jaineshp
Memorable Member
Memorable Member

Hi @Justas4478,

Issue: % of Total Measure Inaccurate When Slicers Are Used

You're calculating the "% of Total Orders" using the following three-part DAX measure:

Total Orders = COUNT('Order data'[Document])

Total Orders Sum = CALCULATE(
[Total Orders],
ALLEXCEPT('Order data', 'Order data'[Customer Group], 'Order data'[Carrier Hub])
)

% of Total Orders = DIVIDE([Total Orders], [Total Orders Sum])

This works fine for the total figures, but breaks down when slicers (like Customer Group or Carrier Hub) are used on the report page — leading to incorrect % values due to context leakage.

Root Cause:

Using ALLEXCEPT removes all filters except those specified. However, your slicers are filtering Customer Group and Carrier Hub, which unintentionally keeps those filters in place and distorts the total used in the denominator.

Solution:

Instead of ALLEXCEPT, use REMOVEFILTERS to explicitly remove only page/report slicers while retaining row-level context within visuals.

Update your measure like this:

Total Orders Sum = CALCULATE(
[Total Orders],
REMOVEFILTERS('Order data'[Customer Group]),
REMOVEFILTERS('Order data'[Carrier Hub])
)

This way, the total is calculated correctly without being influenced by the slicers, and your percentage measure becomes:

% of Total Orders = DIVIDE([Total Orders], [Total Orders Sum])

Result:

  • Now the % values in tables/visuals are accurate.

  • The measure respects interaction context correctly.

  • Slicers no longer distort the total reference base.

Hope this helps! Hit that like button and mark it as solution.

Best Regards,
Jainesh Poojara | Power BI Developer

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.