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
asas27
New Member

How to do the calculation % of counts from a table ?

Hi Sir/Madam,

 

I had a table in the following format.

 

ProductShopDelivery Country
A1US
A1US
A2Canada
A2US
B2US
B3US
B1Canada
B3Canada
B2Canada

 

Then I need to prepare another table to show the following data:

ProductPercentage from Shop 1Percentage to USPercentage from Shop 1 to US
AHow?How?How?
BHow?How?How?

 

Would you mind to teach me how to calculate those % in second table?  Many thanks!

 

Best regards,

Catherine

 

1 ACCEPTED SOLUTION
V-lianl-msft
Community Support
Community Support

Hi @asas27 ,

 

First, create a product table

Table 2 = DISTINCT('Table'[Product])

Create a one to many relationship between the product table and the original table.

Try to create measures like this:

Percentage from Shop 1 =
VAR count_shop1 =
    CALCULATE ( COUNTROWS ( 'Table' ), FILTER ( 'Table', 'Table'[Shop] = 1 ) )
VAR count_all =
    COUNTROWS ( 'Table' )
RETURN
    DIVIDE ( count_shop1, count_all )

test_How to do the calculation % of counts from a table.PNG

Sample .pbix

 

Best Regards,
Liang
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

2 REPLIES 2
V-lianl-msft
Community Support
Community Support

Hi @asas27 ,

 

First, create a product table

Table 2 = DISTINCT('Table'[Product])

Create a one to many relationship between the product table and the original table.

Try to create measures like this:

Percentage from Shop 1 =
VAR count_shop1 =
    CALCULATE ( COUNTROWS ( 'Table' ), FILTER ( 'Table', 'Table'[Shop] = 1 ) )
VAR count_all =
    COUNTROWS ( 'Table' )
RETURN
    DIVIDE ( count_shop1, count_all )

test_How to do the calculation % of counts from a table.PNG

Sample .pbix

 

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

dedelman_clng
Community Champion
Community Champion

Hi @asas27 -

 

You don't give the answers you are specifically looking for, but here's what I think you want:

 

New Measure:

TotalSalesPct = CALCULATE(COUNTROWS('Product')) / CALCULATE(COUNTROWS(ALL('Product')))

 

3 matrix visuals

 

2020-08-10 14_52_56-N_and_BASE_problem (3) - Power BI Desktop.png

Hope this helps

David

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.