Find Percentage of Female from Gender Column — Power-BI
Friends, there is a very simple formula to find female or male percentages from a gender column.
Suppose your objective is to plot a line chart of year-wise female employee percentages from the employee data in Power-BI. The required plot is given below which is created in excel.
Below is the sample employee data ‘data’ provided to you.
You are going to use only two columns Gender and Year to plot the above chart.
In Power-BI, you need to create a ‘New Measure’ for this as —
%Female = COUNTROWS(FILTER(RELATEDTABLE(data),data[Gender]= “Female”)) / COUNTROWS(data)
%Female = COUNTROWS(FILTER(RELATEDTABLE(data),data[Gender]= “Female”)) / COUNTROWS(RELATEDTABLE(data))
- The COUNTROWS function counts the number of rows in the specified table, or in a table defined by an expression.
- The FILTER function returns a table that represents a subset of another table or expression.
- The RELATEDTABLE function evaluates a table expression in a context modified by the given filters.
Once this is created, follow the below steps:
Select ‘Line chart’ from the visualizations section:
In ‘Axis’, add the ‘Year’ column. Note you need to select ‘Don’t Summarize’ for the column ‘Year’ before adding it to the axis (Click on Year column from Fields section and select ‘Don’t summarize’).
And add the ‘%Female’ measure to the ‘Values’.
Do some formatting for Y and X-axis and for data labels then you are done!
Thanks for reading ❤
For any suggestions or queries, leave your comments below and follow for updates.
If you liked the article, please hit the 👏 icon to support it. This will help other Medium users find it. Share it, so that others can read it!
Happy Learning! 😊