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

Get certified in Microsoft Fabric—for free! For a limited time, the Microsoft Fabric Community team will be offering free DP-600 exam vouchers. Prepare now

Reply
blockobito
Helper I
Helper I

How to count Average of Text?

Hi i have a data column Gender 

I need to count Male and Female and the average percentage will be 50% 

 

 

1 ACCEPTED SOLUTION
v-rzhou-msft
Community Support
Community Support

Hi @blockobito ,

 

If you want to calculate the percentage of males and females in the total, you can try this code.

Percentage = 
VAR _Total =
    CALCULATE ( COUNT ( 'Table'[User] ), ALL ( 'Table' ) )
VAR _Each_Gender =
    CALCULATE ( COUNT ( 'Table'[User] ) )
RETURN
    DIVIDE ( _Each_Gender, _Total )

My Sample:

RicoZhou_0-1669968619547.png

Result is as below.

RicoZhou_1-1669968638160.png

 


Best Regards,
Rico Zhou

 

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-rzhou-msft
Community Support
Community Support

Hi @blockobito ,

 

If you want to calculate the percentage of males and females in the total, you can try this code.

Percentage = 
VAR _Total =
    CALCULATE ( COUNT ( 'Table'[User] ), ALL ( 'Table' ) )
VAR _Each_Gender =
    CALCULATE ( COUNT ( 'Table'[User] ) )
RETURN
    DIVIDE ( _Each_Gender, _Total )

My Sample:

RicoZhou_0-1669968619547.png

Result is as below.

RicoZhou_1-1669968638160.png

 


Best Regards,
Rico Zhou

 

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

Tony_Kuiper
Helper I
Helper I

Measure = CountRows(table)

Then place a visual with the gender and the Measure as the column. Can be added twice and use second as % of total.

If you need to split it up into separate records...

Measure Male = 

CALCULATE(COUNTROWS(Table1),Table1[gender] = "Male")
(you will need to ensure that the data is all uniform ie all CAPS or all lower etc I think)

Helpful resources

Announcements
OCT PBI Update Carousel

Power BI Monthly Update - October 2024

Check out the October 2024 Power BI update to learn about new features.

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

October NL Carousel

Fabric Community Update - October 2024

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