Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
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
Check out the July 2025 Power BI update to learn about new features.
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
User | Count |
---|---|
69 | |
68 | |
40 | |
29 | |
26 |
User | Count |
---|---|
86 | |
49 | |
45 | |
38 | |
37 |