Forum Discussion

t-irp's avatar
t-irp
New Member
3 years ago
Solved

Another DAXComparison Operations Do Not Support Comparing Values Of Type Integer With Type Text

Hello, I did a search and found a similar post but despite my efforts to solve my own issue, I am blocked and could use some guidance. I did follow the steps in that other post, which were quite clear by those who responded.

I am creating a Financial report where I need to group "general ledger" codes that are text values but with ranges such as >1000 and <1999, 2000 to 2050, etc. I have 50+ total. I don't want to use the "group by" feature as that seems to only detect values that exist "today" in the ERP. If the Finance team wants to add some new GL codes like 2049, I am looking for a query that will detect that without them having to remember to then add more to the "group by". The goal here is to detect GL codes in ranges.

 

The GL_Code column is of type TEXT, coming in that way from the vendor. We cannot change this in the master system, but tried changing in Power BI but did not see a change in my error messages. As of now, the value for GL has been changed to Whole number," My calculated column is of type "whole number."

 

My query will be massive, but step 1 is getting this working.

ReportValue (DAX) = Switch(TRUE(), NOT(ISBLANK(VALUE(GL_BALANCE_MC[Cost_Center]))) = 1000 , "Cash")

also tried

ReportValue (DAX) = Switch(TRUE(), NOT(ISBLANK(FORMAT(GL_BALANCE_MC[Cost_Center],"Standard"))) == 1000 , "Cash")

and

ReportValue (DAX) = Switch(TRUE(), FORMAT(GL_BALANCE_MC[Cost_Center],"Standard") == 1000 , "Cash")

All give me

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

I have also tried with a single = and a ==.

 

Does anyone see an obvious error or misunderstanding on my part. I hope I described the issue.

  • I made a lot more progress. It seems that the value 1000 is a string, not a number.

    This

    ReportValue (DAX) = Switch(TRUE(), FORMAT(GL_BALANCE_MC[Cost_Center],"Standard") = FORMAT(1000,"Standard"), "Cash")

    gets me past the error. Hopefully it helps someone

  • Sorry for the late reply, = the issue was that "1000" needed to be a string for whatever reason.

8 Replies

  • hi t-irp 

     

    what kind of data do you have for column GL_BALANCE_MC[Cost_Center]?

    • t-irp's avatar
      t-irp
      New Member

      That data coming from the vendor DB is "text". I have selected that column in Power BI and changed to "whole number" but that is not solving my issue, so I am doing something else wrong it seems.

  • They are numbers such as 1000, 1200, 1351, etc, but some are empty/null

    • FreemanZ's avatar
      FreemanZ
      Super User

      hi t-irp 

      not sure about your use case. try like:

      ReportValue (DAX) =

      Switch( TRUE(),NOT(ISBLANK(VALUE(GL_BALANCE_MC[Cost_Center]))) , "Cash")

       

      or why you want to compare with 1000?

      • t-irp's avatar
        t-irp
        New Member

        Hi

        Longer term, I need to create a report that shows this, but for 54 rows.

        ......

        Inventory13001399

        Some number

        Prepaids14001439Some number
        Other Current Assets14401499Some number
        Total Current Assets10001499Some number

        .......

        Note that "Total Current Assets" includes a collection of GL_codes that were already chosen ealier for other groupings. In my mind, I think I should have something like;

         

        ReportValue (DAX) = Switch(TRUE(), NOT(ISBLANK(VALUE(GL_BALANCE_MC[Cost_Center]))) >= 1000 &&  NOT(ISBLANK(VALUE(GL_BALANCE_MC[Cost_Center]))) <= 1499  , "Total Current Access")
         
        But 54 of these in total, one for each line item aggregating the appropriate GL_Codes.
        Cash
        AR - Trade
        AR - Other
        Costs in Excess of Billings
        Intercompany Assets

        50 more....

         
         

         

         

  • I made a lot more progress. It seems that the value 1000 is a string, not a number.

    This

    ReportValue (DAX) = Switch(TRUE(), FORMAT(GL_BALANCE_MC[Cost_Center],"Standard") = FORMAT(1000,"Standard"), "Cash")

    gets me past the error. Hopefully it helps someone

  • Sorry for the late reply, = the issue was that "1000" needed to be a string for whatever reason.