Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago
Solved

Range of Values in SSAS Tabular model

Hi Friends,   Range of values in SSAS tabular model. i have table name 'Total' and column is [DiffDays] and values in column are like, 100, 200, 300, 400, 500. when i am writing same if statement ...
  • Anonymous's avatar
    Anonymous
    6 years ago

    Anonymous Are you trying to create a measure or calculated column in SSAS. If you trying to create a calculated column then it will work and i case you are trying to create a measure you need to wrap the column into aggregate function depends on your requirement
    Something like this

     

    Range = 
    VAR _datediff = MAX('total'[DiffDay])
    RETURN
    SWITCH(TRUE()
                    ,_datediff<=100,"0-100"
                    ,AND(_datediff>100,_datediff<=300),"101-300"
                    ,AND(_datediff>300,_datediff<=500),"301-500"
                   ,"501-above")