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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
majid154a
Frequent Visitor

Dealing with percents

I have data containing the following columns: Category, Sub-Category, Order ID, and Country.

I want to visualize this data using a Matrix chart such that:
- Category and Sub-Category are in the Rows.
- Country is in the Columns.
- The values represent the Order Count.

Requirements:
1. How can I make the order percentages for each Category add up to 100%?
2. When performing a Drill Down on a specific Category to show the Sub-Categories, how can I ensure that the sum of all Sub-Categories equals 100%?
3. How can I ensure that the total percentages in the columns and rows add up to 100%?

What is the method to achieve this in Power BI?

see here convert numbers to percent:

majid154a_0-1721550142478.png

 

 

Attaced data as example: 

Order IDCategorySub-CategoryCountry
1FurnitureChairsUnited States
2OfficePaperUnited States
3TechnologyPhonesUnited States
4FurnitureTablesUnited States
5OfficeBindersUnited States
6TechnologyLaptopsUnited States
7FurnitureBookcasesUnited States
8OfficeArtUnited States
9TechnologyAccessoriesUnited States
10FurnitureFurnishingsUnited States
11OfficeLabelsUnited States
12TechnologyCopiersUnited States
13FurnitureChairsUnited States
14OfficeEnvelopesUnited States
15TechnologyPhonesUnited States
16FurnitureTablesUnited States
17OfficeStorageUnited States
18TechnologyLaptopsUnited States
19FurnitureBookcasesDenmark
20OfficeSuppliesDenmark
21TechnologyAccessoriesDenmark
22FurnitureFurnishingsDenmark
23OfficePaperDenmark
24TechnologyCopiersDenmark
25FurnitureChairsDenmark
26OfficeArtDenmark
27TechnologyPhonesDenmark
28FurnitureTablesDenmark
29OfficeBindersDenmark
30TechnologyLaptopsDenmark
31FurnitureBookcasesDenmark
32OfficeLabelsDenmark
33TechnologyAccessoriesDenmark
34FurnitureFurnishingsDenmark
35OfficeEnvelopesDenmark
36TechnologyCopiersVietnam
37FurnitureChairsVietnam
38OfficeStorageVietnam
39TechnologyPhonesVietnam
40FurnitureTablesVietnam
41OfficeSuppliesVietnam
42TechnologyLaptopsVietnam
43FurnitureBookcasesVietnam
44OfficePaperVietnam
45TechnologyAccessoriesVietnam
46FurnitureFurnishingsVietnam
47OfficeArtVietnam
48TechnologyCopiersVietnam
49FurnitureChairsVietnam
50OfficeBindersVietnam
51TechnologyPhonesVietnam
52FurnitureTablesVietnam
53OfficeLabelsVietnam
54TechnologyLaptopsVietnam
55FurnitureBookcasesVietnam
56OfficeEnvelopesVietnam
57TechnologyAccessoriesVietnam
58FurnitureFurnishingsVietnam
59OfficeStorageVietnam
60TechnologyCopiersVietnam
61FurnitureChairsVietnam
62OfficePaperVietnam
63TechnologyPhonesVietnam
64FurnitureTablesVietnam
65OfficeBindersVietnam
66TechnologyLaptopsVietnam
67FurnitureBookcasesVietnam
68OfficeArtVietnam
69TechnologyAccessoriesVietnam
70FurnitureFurnishingsVietnam
71OfficeLabelsVietnam
72TechnologyCopiersVietnam
73FurnitureChairsVietnam
74OfficeEnvelopesVietnam
75TechnologyPhonesVietnam
76FurnitureTablesVietnam
77OfficeStorageVietnam
78TechnologyLaptopsVietnam
79FurnitureBookcasesVietnam
80OfficeSuppliesVietnam
81TechnologyAccessoriesVietnam
82FurnitureFurnishingsVietnam
83OfficePaperKosovo
84TechnologyCopiersKosovo
85FurnitureChairsKosovo
86OfficeArtKosovo
87TechnologyPhonesKosovo
88FurnitureTablesKosovo
89OfficeBindersKosovo
90TechnologyLaptopsKosovo
91FurnitureBookcasesKosovo
92OfficeLabelsKosovo
93TechnologyAccessoriesKosovo
94FurnitureFurnishingsKosovo
95OfficeEnvelopesKosovo
96TechnologyCopiersKosovo
97FurnitureChairsKosovo
98OfficeStorageKosovo
99TechnologyPhonesKosovo
100FurnitureTablesKosovo
1 ACCEPTED SOLUTION

Hi @majid154a ,

 

Modify measure.

MEASURE = 
VAR _count =
    COUNT ( 'Table'[Order ID] )
VAR _all =
    CALCULATE ( COUNT ( 'Table'[Order ID] ), ALLSELECTED ( 'Table'[Sub-Category]) )
RETURN
    DIVIDE ( _count, _all )

vkaiyuemsft_0-1722244483722.png

 

If your Current Period does not refer to this, please clarify in a follow-up reply.

 

Best Regards,

Clara Gong

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

View solution in original post

5 REPLIES 5
v-kaiyue-msft
Community Support
Community Support

Hi @majid154a ,

 

Thanks for the reply from @Rakesh1705  and @BINewbie1 , please allow me to provide another insight:

 

You can try this measure expression.

MEASURE = 
VAR _count =
    COUNT ( 'Table'[Order ID] )
VAR _all =
    CALCULATE ( COUNT ( 'Table'[Order ID] ), ALLSELECTED ( 'Table' ) )
RETURN
    DIVIDE ( _count, _all )

 

vkaiyuemsft_0-1721724749178.png

vkaiyuemsft_1-1721724757480.png

 

If your Current Period does not refer to this, please clarify in a follow-up reply.

 

Best Regards,

Clara Gong

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

Thank you for helping @v-kaiyue-msft 

In the image below, I need the red circle to represent 100%. Additionally, I need each yellow circle to also represent 100%.

How can we achieve this?

majid154a_0-1722144048115.png

 

Hi @majid154a ,

 

Modify measure.

MEASURE = 
VAR _count =
    COUNT ( 'Table'[Order ID] )
VAR _all =
    CALCULATE ( COUNT ( 'Table'[Order ID] ), ALLSELECTED ( 'Table'[Sub-Category]) )
RETURN
    DIVIDE ( _count, _all )

vkaiyuemsft_0-1722244483722.png

 

If your Current Period does not refer to this, please clarify in a follow-up reply.

 

Best Regards,

Clara Gong

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

Rakesh1705
Resolver III
Resolver III

Source Data

Rakesh1705_0-1721580863132.png

Sub Category order id count formula

Rakesh1705_1-1721580909795.png

Count % formula

Rakesh1705_2-1721580949509.png

Matrix visual elements

Rakesh1705_3-1721580993094.png

 



BINewbie1
Helper II
Helper II

Percentages in Power BI are achieved obviously with the division of a numerator by a denominator.

 

The DIVIDE function is key, but the harder part (as least as i've been learning) in Power BI is understanding a concept called filter context - basically how the tables are populated. For the denominator to work correctly as you want you'll need to remove filters being applied to the numerator. Which filters depend on what you want to divide by. This will be acheived using the REMOVEFILTERS function.

 

This will likley involve removing the filters that apply to country (to give a total of all the orders across countries) and removing the filters on subcategory. To get each one to add up to 100%, probably need to use two different measures.

 

Here's a really helpful video explaining filter context from the nice people as SQLBI:

https://www.youtube.com/watch?v=L5WR-imfyYI 

 

Hope that helps point you in the right direction.

 

Adam

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.