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

Try your skills in the Power BI Dataviz World Championship! Round one ends June 26. Join now

Reply
hjg_1234
New Member

Boolean Data Error

I keep getting the error 'The function COUNTX cannot work with values of type Boolean.' but as far as I can tell I'm working with numbers not Boolean data.

 

I have a column called 'Hotel Eligible' that is all 1s or 0s but the data type is set to Whole number.

 

I am just using a basic measure (below) to test it but am getting the above error - does anyone know what might be causing that? Or they best way to get round it? Sorry for basic question - I'm new to this.

 

 

 

Proportion Hotel Eligible = DIVIDE(COUNTX('Air Detail - Leg (Depart)','Air Detail - Leg (Depart)'[Hotel Eligible]>0),COUNTA('Air Detail - Leg (Depart)'[Hotel Eligible])) 

 

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @hjg_1234 

Make sure that your data type for this field is  Whole number, you can replace countx() with a calculation

 

roportion Hotel Eligible = DIVIDE(COUNTROWS(FILTER(ALLSELECTED('Air Detail - Leg (Depart)'),[Hotel Eligible]>0)),COUNTA('Air Detail - Leg (Depart)'[Hotel Eligible]))

 

 

 

vxinruzhumsft_0-1689649586673.png

And if it cannot work, can you provide some sample picture of the error meaasage?

 

Best Regards!

Yolo Zhu

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Hi @hjg_1234 

Make sure that your data type for this field is  Whole number, you can replace countx() with a calculation

 

roportion Hotel Eligible = DIVIDE(COUNTROWS(FILTER(ALLSELECTED('Air Detail - Leg (Depart)'),[Hotel Eligible]>0)),COUNTA('Air Detail - Leg (Depart)'[Hotel Eligible]))

 

 

 

vxinruzhumsft_0-1689649586673.png

And if it cannot work, can you provide some sample picture of the error meaasage?

 

Best Regards!

Yolo Zhu

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Ritaf1983
Super User
Super User

Please provide sample data that covers your issue or question completely, in a usable format (not as a screenshot).
https://community.powerbi.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-Forum/ba-...
Please show the expected outcome based on the sample data you provided.

https://community.powerbi.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447523

Regards,
Rita Fainshtein | Microsoft MVP
https://www.linkedin.com/in/rita-fainshtein/
Blog : https://www.madeiradata.com/profile/ritaf/profile

Helpful resources

Announcements
Fabric Data Days is here Carousel

Data Days 2026

Don't miss out on Data Days, June 15 through August 7. Learn Fabric, Power BI, SQL, AI and more.

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.