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
biswad
Helper I
Helper I

How to calculate percentage by each group

Hi all, 

 

I have a dataset which consists of the data as shown on the below table "Table -1" , however, I would like to show the data in the power bi dashboard as shown on "Table - 2" where each role_Status were calculated for each Region in percentage wise. I have tried to add measure column for each role status and used if query to count as 1 if there is value in the Role_status or else show blank, then use the sum function to count all the 1s on each role_status and then use  matrix visualization and use role_status on value but I'm unable to represent this data as per table 2 . Any help on this would be greatly appriciated. 

Table -1

Tab1.jpg

 

Tab2.jpg

 

 

2 ACCEPTED SOLUTIONS
lbendlin
Super User
Super User

You can do this without code. Put your data into a matrix visual and show values as percentage of column total.

View solution in original post

v-yiruan-msft
Community Support
Community Support

Hi @biswad ,

You can create a measure as below to get it, please find the details in the attachment.

Percentage = 
VAR _region =
    SELECTEDVALUE ( 'Table'[Region] )
VAR _count =
    CALCULATE (
        COUNT ( 'Table'[Brand] ),
        FILTER ( ALLSELECTED ( 'Table' ), 'Table'[Region] = _region )
    )
VAR _bcount =
    COUNT ( 'Table'[Brand] )
RETURN
    DIVIDE ( _bcount, _count )

vyiruanmsft_0-1707447290373.png

Best Regards

Community Support Team _ Rena
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

3 REPLIES 3
v-yiruan-msft
Community Support
Community Support

Hi @biswad ,

You can create a measure as below to get it, please find the details in the attachment.

Percentage = 
VAR _region =
    SELECTEDVALUE ( 'Table'[Region] )
VAR _count =
    CALCULATE (
        COUNT ( 'Table'[Brand] ),
        FILTER ( ALLSELECTED ( 'Table' ), 'Table'[Region] = _region )
    )
VAR _bcount =
    COUNT ( 'Table'[Brand] )
RETURN
    DIVIDE ( _bcount, _count )

vyiruanmsft_0-1707447290373.png

Best Regards

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

@v-yiruan-msft  that is the perfect solution to my problem, lots of thing to learn, much appriciated you help. I will accept as a solution friend. 

lbendlin
Super User
Super User

You can do this without code. Put your data into a matrix visual and show values as percentage of column total.

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.