Forum Discussion

prasad393's avatar
prasad393
Frequent Visitor
2 years ago
Solved

Function 'SWITCH' does not support comparing values of type Text with values of type True/False.

Hello Folks,

I am fairly new to DAX.

Below is the DAX statement. When I write this I get an error message as BELOW

"Function 'SWITCH' does not support comparing values of type Text with values of type True/False. Consider using the VALUE or FORMAT function to convert one of the values."

 

How can I fix the issue?

 

Greg_Deckler,Vijay_A_Verma 

  • tamerj1's avatar
    tamerj1
    2 years ago

    prasad393 

    =
    SWITCH (
    TRUE (),
    TENT_OVERVIEW[DBA] = "Vacant", "VACANT UNIT",
    TENT_OVERVIEW[LEASE_END_DATE] <= DATE ( 2024, 12, 31 ), "Expiration through 12-31-2024",
    TENT_OVERVIEW[LEASE_END_DATE] > DATE ( 2024, 12, 31 ), "Expiration After 12-31-2024",
    TENT_OVERVIEW[KICKOUT_EXERCISE_START_DATE] <= DATE ( 2024, 12, 31 ), "Kick Out Through 12-31-2024",
    TENT_OVERVIEW[KICKOUT_EXERCISE_START_DATE] > DATE ( 2024, 12, 31 ), "Kick Out After 12-31-2024"
    )

6 Replies

  • tamerj1's avatar
    tamerj1
    Community Champion

    Hi prasad393 

    you need to use SWITCH over TRUE( )

    SWITCH (

    TRUE ( ),

    codition1, result if condition 1 is ture,

    codition2, result if condition 2 is ture,

    .

    .

    .

    )

  • prasad393's avatar
    prasad393
    Frequent Visitor

    Here is the Code.

     

    SWITCH (
        TRUE (),
        TENT_OVERVIEW[DBA], "Vacant", "VACANT UNIT",
        ( TENT_OVERVIEW[LEASE_END_DATE] ) <= 12 / 31 / 2024, "Expiration through 12-31-2024",
        ( TENT_OVERVIEW[LEASE_END_DATE] ) > 12 / 31 / 2024, "Expiration After 12-31-2024",
        ( TENT_OVERVIEW[KICKOUT_EXERCISE_START_DATE] ) <= 20241231, "Kick Out Through 12-31-2024",
        ( TENT_OVERVIEW[KICKOUT_EXERCISE_START_DATE] ) > 20241231, "Kick Out After 12-31-2024"
    )
    • tamerj1's avatar
      tamerj1
      Community Champion

      prasad393 

      =
      SWITCH (
      TRUE (),
      TENT_OVERVIEW[DBA] = "Vacant", "VACANT UNIT",
      TENT_OVERVIEW[LEASE_END_DATE] <= DATE ( 2024, 12, 31 ), "Expiration through 12-31-2024",
      TENT_OVERVIEW[LEASE_END_DATE] > DATE ( 2024, 12, 31 ), "Expiration After 12-31-2024",
      TENT_OVERVIEW[KICKOUT_EXERCISE_START_DATE] <= DATE ( 2024, 12, 31 ), "Kick Out Through 12-31-2024",
      TENT_OVERVIEW[KICKOUT_EXERCISE_START_DATE] > DATE ( 2024, 12, 31 ), "Kick Out After 12-31-2024"
      )