Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.
Hello, I hope my question is an easy one. I've been poking around the forums and reviewing documentation but can't wrap my head around the best way to do this: I have a list of names for items, and want to label these items based on their name. These items use a naming convention where the beginning of the name indicates what group they belong to. I want to add a column with these groups. Take the data below:
Line 1: the item name begins with 'Red-' so this indicates it belongs in the 'Winners' category. My 'Item Name' is being pulled automatically from a resource. I want to add 'Category' so I can easily splice these items.
I have a feeling it will be a variation of @Greg_Deckler 's solution for Attendance, posted here: Solving Attendance with the Disconnected Table Tri... - Microsoft Fabric Community but can't seem to connect the dots. I'd be happy to provide more info if needed. Thank you!
Solved! Go to Solution.
Update for all: I was able to find a working solution to the problem: a (very long) conditional column:
The result is a very ugly string of if statements in a single Power Query, but it accomplished exactly what I was trying to do. Thank you!
Update for all: I was able to find a working solution to the problem: a (very long) conditional column:
The result is a very ugly string of if statements in a single Power Query, but it accomplished exactly what I was trying to do. Thank you!
Hi @jwyoung07
I'm not sure if I have understood it correctly. But, I think you can create a new custom column:
Name Category =
var searchCat =
LEFT(
'MyTable'[Item],
SEARCH(
"-",
MyTable[Item],
,
LEN(MyTable[Item]) + 1
) - 1
)
return SWITCH(searchCat,
"Red","Winners",
"Blue","Losers",
"Yellow","Participators",
"Purple","Try-Hards",
"No category")
I hope it works!
Thanks so much for your quick response @mlsx4 ! Pardon my ignorance, but I'm getting a Token Eof error when making this column:
I'm sure I'm missing something very simple. Please advise, thank you so much!
Hi @jwyoung07
I thought you need it in DAX, so that's why my formula isn't working on M. In M, the solution is the one you has done. I'm glad you finally solved your problem
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
79 | |
73 | |
58 | |
36 | |
32 |
User | Count |
---|---|
90 | |
60 | |
60 | |
49 | |
45 |