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

The ultimate Microsoft Fabric, Power BI, Azure AI & SQL learning event! Join us in Las Vegas from March 26-28, 2024. Use code MSCUST for a $100 discount. Register Now

Reply
batranikhil
Frequent Visitor

Stacked bar chart - % of GT Calculation when using Slicer

Hi, 

I have data from a survey for 1000+ respondents asking what customers are using today vs tomorrow split across 4 dimensions. 

The percentage is calculated as a ratio of that category to the overall count.

 

But when I use the Filters Pane to only show one of the categories, the percentage is recalculated on the new base as per the Filters. Is there a way it is calculated on the grand total and not the sliced value for that. Is there any workaround to avoid this?

 

Here's the sample graph - overall (first image) and the Filtered for USE NOW category only (second image):

 

batranikhil_2-1625729077094.png                          batranikhil_1-1625729021572.png

 

Is there a way I can calculate the the percentage for individual category (e.g. USE NOW in this example) (when filtering on visual for that category) over the grand total instead of the total rows after filtering. 

Here's what the table structure looks like. 

batranikhil_3-1625730080484.png

 

Thanks in advance. 

 

Cheers,

Nikhil

1 ACCEPTED SOLUTION
v-kelly-msft
Community Support
Community Support

Hi @batranikhil ,

 

Create a measure as below:

 

Measure = 
var _count1=CALCULATE(COUNT('Table'[Value]),FILTER(ALL('Table'),'Table'[Value]=MAX('Table'[Value])&&'Table'[Attribute]=MAX('Table'[Attribute])))
var _count2=CALCULATE(COUNT('Table'[Attribute]),FILTER(ALL('Table'),'Table'[Attribute]=MAX('Table'[Attribute])))
Return
DIVIDE(_count1,_count2)

 

And you will see:

vkellymsft_0-1626057251288.png

vkellymsft_1-1626057412919.png

 

For the related .pbix file,pls see attached.

 

Best Regards,
Kelly

Did I answer your question? Mark my post as a solution!

View solution in original post

2 REPLIES 2
v-kelly-msft
Community Support
Community Support

Hi @batranikhil ,

 

Create a measure as below:

 

Measure = 
var _count1=CALCULATE(COUNT('Table'[Value]),FILTER(ALL('Table'),'Table'[Value]=MAX('Table'[Value])&&'Table'[Attribute]=MAX('Table'[Attribute])))
var _count2=CALCULATE(COUNT('Table'[Attribute]),FILTER(ALL('Table'),'Table'[Attribute]=MAX('Table'[Attribute])))
Return
DIVIDE(_count1,_count2)

 

And you will see:

vkellymsft_0-1626057251288.png

vkellymsft_1-1626057412919.png

 

For the related .pbix file,pls see attached.

 

Best Regards,
Kelly

Did I answer your question? Mark my post as a solution!

Thanks Kelly. Will try this. Thanks!

Helpful resources

Announcements
Fabric Community Conference

Microsoft Fabric Community Conference

Join us at our first-ever Microsoft Fabric Community Conference, March 26-28, 2024 in Las Vegas with 100+ sessions by community experts and Microsoft engineering.

February 2024 Update Carousel

Power BI Monthly Update - February 2024

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

Fabric Career Hub

Microsoft Fabric Career Hub

Explore career paths and learn resources in Fabric.

Fabric Partner Community

Microsoft Fabric Partner Community

Engage with the Fabric engineering team, hear of product updates, business opportunities, and resources in the Fabric Partner Community.

Top Solution Authors