Join us for an expert-led overview of the tools and concepts you'll need to pass exam PL-300. The first session starts on June 11th. See you there!
Get registeredPower BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.
I need to calculate a Sex ratio ([male/female]*100) for every year.
I read on the forum to make 3 measure e.g F, M and use sexratio=M/F.
I am having problems calculating the measures F and M, which the numbers shown in the columns Female and male.
Original Excel input
Unpivotted file
In Power BI
Solved! Go to Solution.
Hi,
Do not drag Sex to the column area section. Just drag years to the row area section and then write the 3 measures that i shared with you in my earlier post.
Hi @RonLieuw,
You could create the measure below to calculate the Sex ratio ([male/female]*100) for every year without Unpivot Columns.
Sex_ratio = VAR male = SUM ( Sheet1[Male] ) VAR female = SUM ( Sheet1[Female] ) RETURN DIVIDE ( male, female ) * 100
You could refer to the output below.
Hope it can help you!
Best Regards,
Cherry
Hi Cherry, thanks for showing me this method of calculating the sex ratio before unpivoting the columns. I was not aware you could do it as you proposed.
Does this means that it is not possible to calculate the sex ratio if the tabel has been pivotted?
Hi,
If you want to get your desired result on an unpivoted dataset, try these measures:
Males = CALCULATE(SUM(Data[Aantal]),Data[Sex]="Male")
Females = CALCULATE(SUM(Data[Aantal]),Data[Sex]="Female")
Sex ratio (%) = [Males]/[Females]
Hope this helps.
HI Ashish_Mathur, thanks for your input. This certainly helps!.
Can I conclude that you cannot caculate the sex ratio on a pivotted list?
Hi,
v-piga-msft has already shared that solution with you.
Asish, v-piga-msft solution was for an unpivotted file with columns for male and female!
Hi,
In which case, i am not clear about the terminology you are using. Please show the dataset and the expected result.
Ashish, on the left is is my data set in the data tab view, on the right I have choosen a matrix (left hand) adn some other visuals.
I cannot calculate the sex ratio measure in report tab based on the columns Female and male with the solution provided.
Sorry about the confusion, I hope now it is clear.
Data set in Data tab view
Matrix table in Report view
Hi,
Do not drag Sex to the column area section. Just drag years to the row area section and then write the 3 measures that i shared with you in my earlier post.
Ashish, you the Men. That's the solution I was looking for. Thanks
You are welcome.
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
84 | |
75 | |
68 | |
41 | |
35 |
User | Count |
---|---|
102 | |
56 | |
52 | |
46 | |
40 |