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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
pter14
Frequent Visitor

Creating a visual with measures

Hello guys,

 

In my table there is a category and quantity column, and I would like to show on a visual the share of each category from the total. I created measures for them which calculates the share, but when I try to create the visual, I add the category, then the share and it will show up like this, so it shows the share for each category:

pter14_0-1737974847623.png

Shares are calculated like this: first I created a measure for each category which calculates the total quantity for that category, also created a measure for the sum of the quantites, then created a measure for each of them to calculate the share from the two measures. Feel like I overcomplicated it, could you please assist me with what would be the best option for this?

 

1 ACCEPTED SOLUTION
FarhanJeelani
Super User
Super User

Hi @pter14 ,

 

1.Create a Single Measure for Category Share

Instead of creating individual measures for each category, you can use a single dynamic measure:

Category Share = DIVIDE( SUM('Table'[Quantity]), CALCULATE(SUM('Table'[Quantity]), ALL('Table'[Category])) ) 

This formula calculates the share of each category’s quantity out of the total quantity dynamically.

 2.Use a Stacked Column Chart

  1. Add Category to the Axis of the visual.
  2. Add the Category Share measure to the Values.
  3. Format the visual to display percentage values.

3. Add Tooltips (Optional)

To enhance the visual:

Include additional details in the tooltip, like the total quantity or the raw value for each category, using separate measures.

 

Please mark this as solution if it helps yopu. Appreciate Kudos.

 

 

 

View solution in original post

5 REPLIES 5
FarhanJeelani
Super User
Super User

Hi @pter14 ,

 

1.Create a Single Measure for Category Share

Instead of creating individual measures for each category, you can use a single dynamic measure:

Category Share = DIVIDE( SUM('Table'[Quantity]), CALCULATE(SUM('Table'[Quantity]), ALL('Table'[Category])) ) 

This formula calculates the share of each category’s quantity out of the total quantity dynamically.

 2.Use a Stacked Column Chart

  1. Add Category to the Axis of the visual.
  2. Add the Category Share measure to the Values.
  3. Format the visual to display percentage values.

3. Add Tooltips (Optional)

To enhance the visual:

Include additional details in the tooltip, like the total quantity or the raw value for each category, using separate measures.

 

Please mark this as solution if it helps yopu. Appreciate Kudos.

 

 

 

Dear @FarhanJeelani,

 

Maybe a filter was on, or I dont know, but it looks like it is working now. Thank you for your assist. Could you please clarify what went wrong on my thinking?

Hello @FarhanJeelani,

 

Thank you for the quick solution, unfortunately this is not working for me.
Category Share = DIVIDE( SUM('Table'[Quantity]), CALCULATE(SUM('Table'[Quantity]), ALL('Table'[Category])) )   This formula gives back 100% for all of the categories, and I felt like the numerator and denominator are switched, so i tried:

Category Share = DIVIDE(CALCULATE(SUM('Table'[Quantity]), ALL('Table'[Category])), SUM('Table'[Quantity]))
 This 2nd one I have to divide by 100 and it gives me back percentages, but not the right percentages.

Maybe I am doing something wrong, or you need more clarficiation on the data?

bhanu_gautam
Super User
Super User

@pter14 , Try using 

Create a measure for the total quantity:

TotalQuantity = SUM('YourTable'[Quantity])

 

Than Create a measure for the share of each category:

CategoryShare =
DIVIDE(
SUM('YourTable'[Quantity]),
[TotalQuantity],
0
)

 

Create a bar chart visualization:
Add the Category column to the Axis field.
Add the CategoryShare measure to the Values field.




Did I answer your question? Mark my post as a solution! And Kudos are appreciated

Proud to be a Super User!




LinkedIn






Hello @bhanu_gautam,

 

Thank you for a quick suggestion, unfortunately this did not work. It is giving 100% for all of the categories.

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Top Solution Authors