Forum Discussion

Mahmoodul's avatar
Mahmoodul
Helper I
4 years ago
Solved

How can i handle This Error

Here is my DAX but i am getting Error(dax comparison operations do not support comparing values of type text with values of type date), Van you please help me and correct my DAX.
Report Date is type Date and country_level1 is Type Text.
 
Calls_6 Week % =
VAR actual =
DIVIDE(
[Calls_6 Weeks],
CALCULATE(
[Calls_Total],
FILTER(
ALL(ocb_global_misses_master_pkg),
ocb_global_misses_master_pkg[country_level1]=VALUE(ocb_global_misses_master_pkg[country_level1]) &&
ocb_global_misses_master_pkg[report_date] = VALUE(ocb_global_misses_master_pkg[report_date]))),
0)
RETURN
actual
  • Hi, Mahmoodul 

     

    The usage of 'value': Converts a text string that represents a number to a number. Obviously you can't use it for data type data. You can use values and selectedvalue instead.

    Like this:

    Calls_6 Week % =
    VAR actual =
        DIVIDE (
            [Calls_6 Weeks],
            CALCULATE (
                [Calls_Total],
                FILTER (
                    ALL ( ocb_global_misses_master_pkg ),
                    ocb_global_misses_master_pkg[country_level1]
                        = SELECTEDVALUE ( ocb_global_misses_master_pkg[country_level1] )
                        && ocb_global_misses_master_pkg[report_date]
                            = SELECTEDVALUE ( ocb_global_misses_master_pkg[report_date] )
                )
            ),
            0
        )
    RETURN
        actual
    

    Reference:

    VALUES function (DAX) - DAX | Microsoft Docs

    SELECTEDVALUE function - DAX | Microsoft Docs

     

    Did I answer your question ? Please mark my reply as solution. Thank you very much.
    If not, please feel free to ask me.


    Best Regards,
    Community Support Team _ Janey

2 Replies

  • vanessafvg's avatar
    vanessafvg
    Community Champion

    The issue is most likely this line, 

     

    ocb_global_misses_master_pkg[report_date] = VALUE(ocb_global_misses_master_pkg[report_date]

     

    you are using a text function with a date, and you can't do that.  What are you trying to do?  Why not just compare  the 2 dates?

     

     

  • v-janeyg-msft's avatar
    v-janeyg-msft
    Community Support

    Hi, Mahmoodul 

     

    The usage of 'value': Converts a text string that represents a number to a number. Obviously you can't use it for data type data. You can use values and selectedvalue instead.

    Like this:

    Calls_6 Week % =
    VAR actual =
        DIVIDE (
            [Calls_6 Weeks],
            CALCULATE (
                [Calls_Total],
                FILTER (
                    ALL ( ocb_global_misses_master_pkg ),
                    ocb_global_misses_master_pkg[country_level1]
                        = SELECTEDVALUE ( ocb_global_misses_master_pkg[country_level1] )
                        && ocb_global_misses_master_pkg[report_date]
                            = SELECTEDVALUE ( ocb_global_misses_master_pkg[report_date] )
                )
            ),
            0
        )
    RETURN
        actual
    

    Reference:

    VALUES function (DAX) - DAX | Microsoft Docs

    SELECTEDVALUE function - DAX | Microsoft Docs

     

    Did I answer your question ? Please mark my reply as solution. Thank you very much.
    If not, please feel free to ask me.


    Best Regards,
    Community Support Team _ Janey