Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
BotBot1
Helper III
Helper III

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 need "Innovation" and "Exceeding company standards" to be in Positive, "Company standard" to be Neutral, "Unknown" to be Unknown, and the rest to be in Negative. This is coming from the variable [CategoryTypeName] within the "HSE Observation" field. I have attempted at writing the DAX, but I believe I need an aggregate function within it to calculate the totals for each/DAX to recognise the column. 

 

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

 

If the DAX can be adjusted to include the function that would be great, thank you.

1 ACCEPTED SOLUTION
tamerj1
Super User
Super User

Hi @BotBot1 
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"
    )

View solution in original post

1 REPLY 1
tamerj1
Super User
Super User

Hi @BotBot1 
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"
    )

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.