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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
kracrde
Frequent Visitor

Question on data formatting

Hi all,

 

I have a problem with data formatting I am not able to resolve myself. I hope someone can give me a good hint on how to solve it.

I have a table with item numbers, description etc. The item numbers have unfortunately various formats (this is due to the bad data governance in our company). Some item numbers have 4,5 or 6 digits (e.g. 9718 or 78644). We also have special item numbers, e.g. 78644-0001 and M78644)

I have the article category group in a separate table and I would like to match them together with a relationship. The thing is, that I only have the category available for the first 5 digits, means 78644-0001  is not recognized and therefore no category is assigned to it.

I would like to format the item numbers in a way, that all the items with a -000X end are interpreted as 78644 only.

Is there a way to do it? I have come close to it by creating a separate column with only the first 5 digits, but items like M78644 are then not recognized.

 

Anyone an idea how to solve it?

 

1 ACCEPTED SOLUTION
affan
Solution Sage
Solution Sage

Hi @kracrde,

 

You can model your data using the Query editor. As you have different cases in the data, some are having a delimiter '-' and some are starting with an alphabet. You need to apply the cleanup to all cases. Please see the video below that I created for you.

 

 

If this helped you, please mark this post as an accepted solution and like to give KUDOS .

 

Regards,

Affan

View solution in original post

5 REPLIES 5
affan
Solution Sage
Solution Sage

Hi @kracrde,

 

You can model your data using the Query editor. As you have different cases in the data, some are having a delimiter '-' and some are starting with an alphabet. You need to apply the cleanup to all cases. Please see the video below that I created for you.

 

 

If this helped you, please mark this post as an accepted solution and like to give KUDOS .

 

Regards,

Affan

Anonymous
Not applicable

Hi,

 

Can you try this formula for your calculated column?

 

 

Item =
IF (
    LEFT ( RIGHT ( Table1[ItemNumbers], 4 ), 3 ) = "000",
    LEFT ( Table1[ItemNumbers], 5 ),
    Table1[ItemNumbers]
)

 

Sample Output

 

Original Item NumerItem
M78644M78644
78644-00178644
7864478644
78644-00578644

 

This formula is only to test the logic as I have assumed that minimum there will be 5 characters. If you have items with length less than 5 characters, error will happen. You have to use IFERROR function to handle that error.

 

 

 

hi sreenathv

 

thank you for your quick reply. your formula has brought me a step further.

The numbers are correctly formatted except all which have an ending -0010 and higher.

All endings between -0001 and -0009 are fine.

 

e.g. 78644-0001 to 78644-0009 are ok

78644-0010 to 78644-9999 still show the -ending.

@kracrde Please try this in "Power Query Editor" by adding a "Custom Column"

 

if Value.Is(Value.FromText(Text.End([Value],4)),type number) and Text.Start(Text.End([Value],5),1) = "-" then "78644" else [Value]

 

 image.png





Did I answer your question? Mark my post as a solution!

Proud to be a PBI Community Champion




@kracrde If you want to do it in Power Query, please try "Custom Column" as below

 

if Text.Start(Text.End([Value],5),4) = "-000" then "78644" else [Value]




Did I answer your question? Mark my post as a solution!

Proud to be a PBI Community Champion




Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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