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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

Find percentage of employee names according to state

Hello so imagine a table where i have 5 names : james, katie,jane,ari,jack. And each name is from a state on another table

 

total employees are 100 and like 20 james, 10 katie , 30 jane , 5 ari, 35 jack

 

 

 

i want to calculate the ratio of each employee name so like i have total james from california are 5 and total james are 20 so  5/20 *100 is 25% .... ect

 

NB: NAMES ARE IN A TABLE SO I HAVE 1 column its name : 

 

Name: state:

 

James california

 

James dakota

 

James california

 

James new jersey

 

.....

 

 

 

i appreciate the help

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Anonymous ,

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

Ratio of each employee name = 
VAR _selstate =
    SELECTEDVALUE ( 'Table'[State] )
VAR _selname =
    SELECTEDVALUE ( 'Table'[Name] )
VAR _nscount =
    CALCULATE (
        COUNT ( 'Table'[Name] ),
        FILTER (
            ALLSELECTED ( 'Table' ),
            'Table'[Name] = _selname
                && 'Table'[State] = _selstate
        )
    )
VAR _ncount =
    CALCULATE (
        COUNT ( 'Table'[Name] ),
        FILTER ( ALLSELECTED ( 'Table' ), 'Table'[Name] = _selname )
    )
RETURN
    DIVIDE ( _nscount, _ncount, 0 )

yingyinr_0-1658742430517.png

Best Regards

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Hi @Anonymous ,

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

Ratio of each employee name = 
VAR _selstate =
    SELECTEDVALUE ( 'Table'[State] )
VAR _selname =
    SELECTEDVALUE ( 'Table'[Name] )
VAR _nscount =
    CALCULATE (
        COUNT ( 'Table'[Name] ),
        FILTER (
            ALLSELECTED ( 'Table' ),
            'Table'[Name] = _selname
                && 'Table'[State] = _selstate
        )
    )
VAR _ncount =
    CALCULATE (
        COUNT ( 'Table'[Name] ),
        FILTER ( ALLSELECTED ( 'Table' ), 'Table'[Name] = _selname )
    )
RETURN
    DIVIDE ( _nscount, _ncount, 0 )

yingyinr_0-1658742430517.png

Best Regards

technolog
Super User
Super User

Hi!

 

You can try create calculated table:

Calc table = SUMMARIZE( 'Table 1', 'Table 1'[Name], "NameCount", COUNT('Table 1'[ID]) )

And then add calc column to this table:

Calc column = DIVIDE ( [NameCount] , SUM( [NameCount] )

 

Please send me screenshots if it doesn't work!

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.