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

Level up your Power BI skills this month - build one visual each week and tell better stories with data! Get started

Reply
TimAnymouse
Regular Visitor

Calculate function with Boolean filter

Good Afternoon,


Hopefully someone can help me with the below.

I am trying to create the below measure but get a blank value when used with a card visual with no filter

Gender Ratio =
var FemalePopulation = CALCULATE(Countries[Population], Countries[Gender] = "Female")
var MalePopulation = CALCULATE(Countries[Population], Countries[Gender] = "Male")

Return
DIVIDE(FemalePopulation, MalePopulation)

As a test I tried the below which also returns blank

 

test = CALCULATE(AVERAGE(Countries[Population]), (Countries[Gender] = "Male"))


I then tried to use summarize but got a syntax error

Table =
SUMMARIZE(Countries,Countries[Country Code],Countries[Age Range],Countries[Year],
DIVIDE(
CALCULATE (Countries[Population], Countries[Gender] = "Female"),
CALCULATE(Countries[Population], Countries[Gender] = "Male"))
)


Kind regards,

Tim

1 ACCEPTED SOLUTION
HotChilli
Community Champion
Community Champion

There's no aggregation i.e. SUM, COUNT, AVERAGE in the first measure shown.

The 2nd one will give results if the datatypes on the columns are correct and there's no spaces or case differences in the Gender column.

 

2 things to try:

Can you post a small sample of data please (not a picture) and say what the desired outcome is?

 Maybe you could create a measure 

AVERAGE(Countries[Population])

and just test that on a card.  You could apply a filter from the filter pane (using Gender to test Male/Female) to further test.

View solution in original post

2 REPLIES 2
HotChilli
Community Champion
Community Champion

There's no aggregation i.e. SUM, COUNT, AVERAGE in the first measure shown.

The 2nd one will give results if the datatypes on the columns are correct and there's no spaces or case differences in the Gender column.

 

2 things to try:

Can you post a small sample of data please (not a picture) and say what the desired outcome is?

 Maybe you could create a measure 

AVERAGE(Countries[Population])

and just test that on a card.  You could apply a filter from the filter pane (using Gender to test Male/Female) to further test.

Thanks, it was a leading space.

 

Helpful resources

Announcements
April Power BI Update Carousel

Power BI Monthly Update - April 2026

Check out the April 2026 Power BI update to learn about new features.

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.