Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago

Help with Return IF function within a measure calculation

Hello Experts,

I am trying to complete a measure calculation, however, facing issue with below error -

"DAX comparison operations do not support comparing values of type True/False with values of type Text. Consider using the VALUE or FORMAT function to convert one of the values."


Basically there are 2 calculations one for the employee and other for the contractor. I have horizontal bar chart, wherein I will be displaying the utilization per resource name. The chart has resource name on axis and on value place utilization ratio measure is used.
What is needed is, if Resource_type is Employee then use employee_utilization calculation else user other.


Here is my measure calculation -

Utilization_Ratio =

VAR Employee_Utilization = ( ('Table1'[Total_Days]) / (Another_Measure * 'Table1'[X_Column]) )*100

VAR Contractor_Utilization = ( ('Table1'[Total_Days]]) / (SUM('Table1'[Non_Billable_Hours]) + SUM('Table1'[Billable_Hours]) ) * 100 )

Return IF(ISFILTERED('Table1'[Resource_Type]) = "Employee", Employee_Utilization, Contractor_Utilization)

 

Kindly let me know where to apply the formatting to number as per the error.

 

Regards,

Abhay

 

4 Replies

  • Greg_Deckler's avatar
    Greg_Deckler
    Community Champion

    I think for this part:

     

     IF(ISFILTERED('Table1'[Resource_Type]) = "Employee", Employee_Utilization, Contractor_Utilization)

     

    You want

     

    IF(MAXX('Table1',[Resource_Type]) = "Employee" ...

     

     

    • Anonymous's avatar
      Anonymous
      Not applicable
      Thanks for the reply. I tried it, however, it says parameter is not of correct type, and also cannot find [Resource_Type].
  • AlB's avatar
    AlB
    Community Champion

    Hi Anonymous 

    ISFILTERED('Table1'[Resource_Type]) yieds a boolean (TRUE/FALSE) value and you are comparing it to "Employee", which is text. That seems to be the cause for the error. IF it is a measure as you said, you probably need something like this instead:

    SELECTEDVALUE('Table1'[Resource_Type]) = "Employee"

    Please mark the question solved when done and consider giving kudos if posts are helpful.

     Cheers 

     

     

    • Anonymous's avatar
      Anonymous
      Not applicable
      Thanks. Worked it well.