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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
laurencowie
Regular Visitor

% of total using dynamic filters but unaffected by TopN filter

Hello! Hopefully somebody can help...

 

Is it possible to calculate a percentage total which changes dynamically based on other filters/slicers on the page, but is not affected by filtering the table to show the top 10 results?

 

For example, I have sales by date, business and category. For each of these I will have a slicer to allow a subset to be considered. I have calculated the %Total Sales, so that if I have all the data, its the percentage of all sales, but if I choose for example just one business, it´s the percentage of that business:

 

All data combined:

 

DateBusinessCategorySalesPercentRank
01/07/2018A110011%4
01/07/2018A215017%2
01/06/2018A112514%3
01/07/2018B1759%6
01/07/2018B2253%7
01/07/2018C130034%1
01/07/2018C210011%4

 

 

 

Filtered for Business A:

 

DateBusinessCategorySalesPercentRank
01/07/2018A110027%3
01/07/2018A215040%1
01/06/2018A112533%2

 

 

Now, I want to only show the top observation based on the variable percent. If I just say, filter for highest percentage, or for rank=1, it recalculates the percentage to be 100%. Can I change it to ignore only the top n filter, and still calculate the percentage based on all other active filters?

 

Many thanks in advance!

 

 

4 REPLIES 4
Greg_Deckler
Super User
Super User

Sounds kind of like an ALLEXCEPT where you exclude Rank. But, I would probably try CALCULATETABLE where you change the filter for Rank to ALL('Table'[Rank]) (column version of ALL) which might remove the TOPN filter if it is based on Rank.


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Thanks Greg.

 

I think ALLEXCEPT would work if Rank was a column, but I need it to be a measure so that it changes with the filters.

 

I have had a look at the CALCULATETABLE function but I'm afraid I don't follow what you mean, or understand exactly how to use the function. Again it seems to not like the fact that rank is a measure. Is that correct or have I misunderstood?

OK, if you post your Rank measure formula, I'll see if I can come up with a full solution.


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Ok, so below is my measure for rank, and my measure for the percent_sales which is the measure I would like to change based on the other filters but not be affected by setting the table to show rank 1-10 only. (Equally, I could use the TopN filter on my BaseItems using top 10 based on Sales column if that is more straightforward, but that also doesn't seem to be working correctly with the ALLEXCEPT!)

 

Ranking= RANKX( ALL(report_excel[BaseItem]); calculate(SUM(report_excel[Sales] )))

 

percent_sales =

   VAR Sales =
       CALCULATE(SUM ( report_excel[Sales] ))
   VAR AllSales =
       CALCULATE( SUM ( report_excel[Sales] ); ALLselected('report_excel'))
   RETURN
       DIVIDE ( Sales; AllSales )

 

 

Thanks for your help!

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.