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! Learn more

Reply
BotBot1
Helper III
Helper III

Categorising Observations into Ratings

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 for this but if I could receieve any help for where I went wrong it would be hugely appreciated.

 

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")

 

I cannot use Data Groups or Power Query so has to be a DAX. Thank you.

4 REPLIES 4
tamerj1
Super User
Super User

Hi @BotBot1 

in which table are creating this column? What is the relationship between this table and 'HSE Observation'?

Hi @tamerj1,

 

I'm not too sure on this, but I am connected to a live dataset (SQL) whereby HSE Observation is the field and CategoryTypeName is one of the variables within the field. I have a measure of 'count of observations' which is where I want to get the number of positive/neutral/negative/unknown ratings from. I currently have a pie chart where it breaks it down the approx. 15 different category names (e.g. company standard, innovation...), but I just want to categorise these into the 4 ratings. I hope this helps, thanks 

hi @BotBot1 

Try like:

Rating =
SWITCH(
    TRUE(),
    [CategoryTypeName] IN {"Innovation", "Exceeding Company Standards"}, 
   "Positive",
   CategoryTypeName] = "Company Standard", 
   "Netural",
    [CategoryTypeName] = "Unknown", 
   "Unknown", "Negative"
)

Hi @FreemanZ

 

Thanks for this. I recieve the below message when inputting this. I am not sure how to but if I could have a COUNT be added to get the total number per new category that would be great, thank you.

 

BotBot1_0-1674725065957.png

 

Helpful resources

Announcements
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!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

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.