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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
Hyperchef1969
Helper V
Helper V

creating categories based on first character of text field

Hi,

 

I have a database column which contains workorder numbers (format text - contains alpha numeric characters). I want to create categories based on the first character of the workorder which can be the number 1 to 9. The workorder numbers which start with 2 and 5 are one group, the numbers which start with 3,5, and 7 are the second group. The numbers with 8 and 9 are 2 separate groups. The remaining numbers (1 and 😎 are leftovers and are valid when the not belonging to the first groups.

 

Tried with if-or calculation but I get the message that I only can use 2 nested or's. Tried also SWTICH function but not succesfully.

 

Can somebody help?

 

Thanks in advance.

 

 

1 ACCEPTED SOLUTION
v-yuezhe-msft
Microsoft Employee
Microsoft Employee

@Hyperchef1969,

Create the following column in your table.

GROUP = IF(LEFT(Table[workoder],1) IN {"2","5"},"G1",IF(LEFT(Table[workoder],1) IN {"3","4","7"},"G2",IF(LEFT(Table[workoder],1)="6","G3",IF(LEFT(Table[workoder],1)="9","G4","G5"))))

1.PNG


If the above DAX doesn't work, please share sample data of your table here.

Regards,
Lydia

Community Support Team _ Lydia Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

1 REPLY 1
v-yuezhe-msft
Microsoft Employee
Microsoft Employee

@Hyperchef1969,

Create the following column in your table.

GROUP = IF(LEFT(Table[workoder],1) IN {"2","5"},"G1",IF(LEFT(Table[workoder],1) IN {"3","4","7"},"G2",IF(LEFT(Table[workoder],1)="6","G3",IF(LEFT(Table[workoder],1)="9","G4","G5"))))

1.PNG


If the above DAX doesn't work, please share sample data of your table here.

Regards,
Lydia

Community Support Team _ Lydia Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.