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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
layheart
Regular Visitor

Dax Statement Help - Grouping codes by If statements

In my data set, I have a column of thousands of unique codes that are about 15 characters in length (ex. 17.26AZ85894) .  I am trying to find a solution to group them to easily sort the data.  I have made a new column to show just the first 5 characters (Stem+2 = 17.26).  From the Stem +2, I made a new column, Componenet Type.  However there is one code with in Stem +2, 17.26, that I need to exlcude from the "Bulk Equipment" group.

 

Example of If statement:  Component Type = IF( Metric Table [Stem +2] = "17.26"  && Except(Stem +5 = "17.264YZ" , "Bulk Equipment", "null")

 

Mainly, I want to exclude one code from my all encompassing 17.26 if statement.

 

Please let me know if this is unclear and I will try to better explain my problem.

 

Thank you in advance!

1 ACCEPTED SOLUTION
stretcharm
Memorable Member
Memorable Member

Unless I'm missing something you can use not equal

 

from the original code  

IF( Left(Metric Table [Code],5) = "17.26"  && Left(Metric Table [Code],8) <> "17.264YZ" , "Bulk Equipment", "null") 

or using 2 columns

 

 

 IF( Metric Table [Stem +2] = "17.26"  && Metric Table [Stem +5] <> "17.264YZ" , "Bulk Equipment", "null")

You can also do similar functions in M (Query Editor)

 

Depending on what your data looks like you may be better creating a mapping table and joining the code or a sub part of the code to the mapping table.

 

For smaller grouping exerecises try the group banding feature. Right click on a column and select New Group.

 

 

View solution in original post

2 REPLIES 2
v-ljerr-msft
Microsoft Employee
Microsoft Employee

Hi @layheart,

 

Have you tried the solution provided by @stretcharm above? Does it work in your scenario? If it works, could you accept it as solution to close this thread?

 

If you still have any question on this issue, feel free to post here. Smiley Happy

 

Regards

stretcharm
Memorable Member
Memorable Member

Unless I'm missing something you can use not equal

 

from the original code  

IF( Left(Metric Table [Code],5) = "17.26"  && Left(Metric Table [Code],8) <> "17.264YZ" , "Bulk Equipment", "null") 

or using 2 columns

 

 

 IF( Metric Table [Stem +2] = "17.26"  && Metric Table [Stem +5] <> "17.264YZ" , "Bulk Equipment", "null")

You can also do similar functions in M (Query Editor)

 

Depending on what your data looks like you may be better creating a mapping table and joining the code or a sub part of the code to the mapping table.

 

For smaller grouping exerecises try the group banding feature. Right click on a column and select New Group.

 

 

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

Find out what's new and trending in the Fabric Community.

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

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! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

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