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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
poojik
Frequent Visitor

Error: DAX comparison operations do not support comparing values of type true/false

I am trying to create a new calcuated field to count all the account names if "ValidationStatus" is TRUE. The formula I am using is : 

 

Validated count = CALCULATE(DISTINCTCOUNT(accounts[name]),FILTER(accounts,VALUE(accounts[validationstatus])= TRUE()))

 

I am getting this error : 

DAX Comparision operations do not support comparing values of type Number with values of type True/False. Consider using value or FORMAT function to convert one of the values. 

 

Any help will be appriciated. 

 

Best

P

 

9 REPLIES 9
Anonymous
Not applicable

Can someone help me please. I have the following code and I keep getting this error. I have tried wrapping the calculate statement in a VALUE function and I get the message, cannot convert true/false.

 

Inpatient comment =
var newline2 =
"
"
return
if(
CALCULATE([Per Member % Change],'Benefit Mapping'[Benefit Type]="inpatient">0.05),"Inpatient Costs:" & newline2 & "The average inpatient cost per member has increased year-over-year by " &FORMAT(CALCULATE([Per Member % Change],'Benefit Mapping'[Benefit Type]="inpatient"), "currency")& ". IP costs are sporadic in nature and can significantly increase or decrease overall costs; in this instance, IP increased overall costs",
if (
AND(CALCULATE([Per Member % Change],'Benefit Mapping'[Benefit Type]="inpatient")<=0.05,CALCULATE([Per Member % Change],'Benefit Mapping'[Benefit Type]="inpatient")>=-0.05 ),"inpatient Costs: " & newline2 & "The average inpatient cost per member has been roughly stable year-over-year (" &FORMAT(CALCULATE([Per Member % Change],'Benefit Mapping'[Benefit Type]="inpatient"), "currency")& " change year-over-year. IP costs are sporadic in nature and can significantly increase or decrease overall costs; in this instance, IP had minimal impact on overall costs",
"Inpatient Costs:" & newline2 & "The average inpatient cost per member has decreased year-over-year by " &FORMAT(CALCULATE([Per Member % Change],'Benefit Mapping'[Benefit Type]="inpatient"), "currency")& ". IP costs are sporadic in nature and can significantly increase or decrease overall costs; in this instance, IP reduced overall costs"

))
Vvelarde
Community Champion
Community Champion

@poojik

 

Hi try with this

 

Validated Count =
CALCULATE (
    DISTINCTCOUNT ( Accounts[name] );
    FILTER ( Accounts; Accounts[validationstatus] = TRUE () )
)

Regards

 

Victor




Lima - Peru

@Vvelarde

This was the first thing I tried previously but it didn't work. 

 

 

Vvelarde
Community Champion
Community Champion

@poojik

 

Double Check the Data Type

 

iMG2.png

 

With this this work:

 

IMG3.png

 

Regards

Victor




Lima - Peru

The data type in Power BI desktop is True/False and the solution 

Validated Count =
CALCULATE (
    DISTINCTCOUNT ( Accounts[name] );
    FILTER ( Accounts; Accounts[validationstatus] = TRUE () )
)

works for power BI desktop. But when I publish the report on Power BI pro online. The data values chages to 0 and -1 hence the solution doesn't work.

 

I am not able to edit the expression in power BI pro to make it compatible. 

 

Hi @poojik,

 

Can you share a sample of the data?

 

Best Regards,

Dale

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

Hi @v-jiascu-msft 

 

The test data is attached. The data is downloaded from Dynamics CRM accounts entity. There are 6 fields with data in 14 rows :

1. Name : Text field

2. Validation status : Option set

3. Created on : Date and Time field

4. Rsubmitted : Option set

5. Units : Whole Number

6. Region : Text field 

'

Now because I have to find out the absolute percentage of names that has Rsubmitted as "Yes"  (example out of 4 Toronto records 3 has Rsubmitted as "Yes". Hence the percentage is 75%)

 

To find out hte percentage i have created a calcuated field : 

 

Validated count =CALCULATE(DISTINCTCOUNT(accounts[name]),accounts[Rsubmitted]= "TRUE")

 

Absolute_percentage = (([Validated count])/(count(accounts[Name])))

 

The calculations are valid and am able to plot stacked bar graph (Screen-shot attached)

 

But when I try to publish this graph to Power BI pro- the data type for Rsubmitted" changes from TURE/FLASE to 1/0 (Screen-shot attached)

after publishing-to-power-bi-pro.pngbefore-publishing.pngafter publishing-to-power-bi-pro.pngbefore-publishing.png2018-06-07 15_43_54-test-data-power-BI-community.png

Anonymous
Not applicable

Try this:

 

CALCULATE(DISTINCTCOUNT(accounts[name]),accounts[validationstatus])= "TRUE")

I am still getting the same error. Screen-shot attached. 

test.png

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.