Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I want to count the total number of males and females in a powerbi report

eg.

Name    Gender
std1    Female
std2    Male
std3    Female
std4    Male
std5    Male
std6    Male

The result I want is:

Female 2
Male   4
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
426 views
Welcome To Ask or Share your Answers For Others

1 Answer

To get the results you are looking for, follow these steps:

  1. Make a second table using the New Table button with the following code:

    GenderCounts = DISTINCT(TableName[Gender])
    
  2. Make a relationship from the newly create table back to the original table Relationship on Gender column

  3. Add a new column to the GenderCounts table with the following code:

    Count = COUNTROWS(RELATEDTABLE(TableName))
    

And there you have a second table containing the counts of each gender. Results

For more information and other possibilities, check out a related Power BI Community forum post here and Stackoverflow questions here and here.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...