Calculate Total male Total Female in powerbi report

家住魔仙堡 提交于 2019-12-13 23:51:53

问题


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

回答1:


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

  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.

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



来源:https://stackoverflow.com/questions/44746142/calculate-total-male-total-female-in-powerbi-report

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!