locked
DAX SWITCH() error "'SWITCH' does not support comparing values of type Integer with values of type True/False" RRS feed

  • Question

  • i've got a measure called [Dax Attribute Density], and its' possible values range from 1 to 100.  Rather than put [Dax Attribute Density] on a slicer directly I want to create a second measure that groups these values into buckets of 1-10, 11-20, 21-30 etc and slice my pivots according to those. 

    This SWTICH() statement is giving said error and I don't understand why since [Dax Attribute Density]values are numbers.

    Freq = SWITCH(
     [Dax Attribute Density],
     [Dax Attribute Density] >=1 && [Dax Attribute Density]<=10 , "1 to 10",  
     [Dax Attribute Density]>=11 && [Dax Attribute Density]<=20 , "11 to 20" , 
    "etc") 

     I want to get past this error and be able to slice the [Dax Attribute Density] according to groupings.  What can be done if not SWITCH?


    • Edited by AitchK Wednesday, March 29, 2017 3:10 AM
    Wednesday, March 29, 2017 2:06 AM

Answers

  • Try changing the first argument of SWITCH() to TRUE() like this:
    Freq = SWITCH(
     TRUE(),
     [Dax Attribute Density] >=1 && [Dax Attribute Density]<=10 , "1 to 10",  
     [Dax Attribute Density]>=11 && [Dax Attribute Density]<=20 , "11 to 20" , 
    "etc") 

    • Marked as answer by AitchK Wednesday, March 29, 2017 5:48 AM
    Wednesday, March 29, 2017 3:40 AM
    Answerer

All replies

  • Try changing the first argument of SWITCH() to TRUE() like this:
    Freq = SWITCH(
     TRUE(),
     [Dax Attribute Density] >=1 && [Dax Attribute Density]<=10 , "1 to 10",  
     [Dax Attribute Density]>=11 && [Dax Attribute Density]<=20 , "11 to 20" , 
    "etc") 

    • Marked as answer by AitchK Wednesday, March 29, 2017 5:48 AM
    Wednesday, March 29, 2017 3:40 AM
    Answerer
  • That works. Thanks again!

    I discovered can't put measures on slicer so I used same formula for calc column and put that on slicer.  Slowly making conversion from SQL based dataset and calculations to raw tables + DAX!







    • Edited by AitchK Wednesday, March 29, 2017 6:05 AM
    Wednesday, March 29, 2017 5:48 AM