Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
3 years ago
Solved

DAX For Categorising Observations

Hi,   I have observations that need to be categorised into their rating groups, being "Positive", "Neutral", "Negative" and "Unknown" based on some of the descriptions within the variable.    I n...
  • tamerj1's avatar
    3 years ago

    Hi Anonymous 
    If you are creating a measure then try

    Observation Category Rating =
    VAR ObservationCategories =
        SELECTEDVALUE ( 'HSE Observation'[CategoryTypeName] )
    RETURN
        SWITCH (
            ObservationCategories,
            "Innovation", "Positive",
            "Exceeding Company Standards", "Positive",
            "Company Standard", "Netural",
            "Unknown", "Unknown",
            "Negative"
        )

    If you are creating a calculated column then try

    Observation Category Rating =
    VAR ObservationCategories =
        'HSE Observation'[CategoryTypeName]
    RETURN
        SWITCH (
            ObservationCategories,
            "Innovation", "Positive",
            "Exceeding Company Standards", "Positive",
            "Company Standard", "Netural",
            "Unknown", "Unknown",
            "Negative"
        )