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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
BidyaSingha
Frequent Visitor

Show percentage of a number of items in a column compared with the total row count of table

Hello connection,

 

Below measure display the value of "dept1" only. We can write different measure for other department.
It is possible to write the single measure to get all different department  percentage, Is this achievable?

 

Below is the "dept1" measure. Instead of writing different measure for different department can we write in single measure?

BidyaSingha_0-1700223222260.png

Measure = 
VAR _A =
    CALCULATE(
        COUNTA( 'Table'[names] ),
        FILTER( ALL( 'Table' ), 'Table'[names] = "dept1" )
    )
VAR _B =
    CALCULATE( COUNTA( 'Table'[names] ), ALL( 'Table' ) )
RETURN
    _A / _B


Thank in advance.

1 ACCEPTED SOLUTION
sjoerdvn
Super User
Super User

Measure = IF (HASONEVALUE('Table'[names]),
    VAR cur_name = VALUES( 'Table'[names])
    RETURN DIVIDE(
        CALCULATE( COUNTA( 'Table'[names]), ALL( 'Table' ), 'Table'[names] = cur_name )
        ,CALCULATE( COUNTA( 'Table'[names]), ALL( 'Table' ))
    )
)

View solution in original post

3 REPLIES 3
tamerj1
Super User
Super User

Hi @BidyaSingha 
Please try

Measur =
VAR _A =
    COUNTROWS ( 'Table' )
VAR _B =
    CALCULATE ( COUNTROWS ( 'Table' ), ALL ( 'Table'[names] ) )
RETURN
    _A / _B
sjoerdvn
Super User
Super User

Measure = IF (HASONEVALUE('Table'[names]),
    VAR cur_name = VALUES( 'Table'[names])
    RETURN DIVIDE(
        CALCULATE( COUNTA( 'Table'[names]), ALL( 'Table' ), 'Table'[names] = cur_name )
        ,CALCULATE( COUNTA( 'Table'[names]), ALL( 'Table' ))
    )
)
Rupak_bi
Impactful Individual
Impactful Individual

try this

Measure = 
VAR _A =
    CALCULATE(
        COUNTA( 'Table'[names] ),
        FILTER( ALLexcept( 'Table' , 'Table'[names] ) )
    )
VAR _B =
    CALCULATE( COUNTA( 'Table'[names] ), ALL( 'Table' ) )
RETURN
    _A / _B


Regards
Rupak
FOLLOW ME : https://www.linkedin.com/in/rupaksar/

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.