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
icdns
Post Patron
Post Patron

Dax to Remove certain characters from column

Hi, 

 

Would like to ask for your assistance to removing certain characters from column. Just like to remove characters on the first part of the word. 

 

Below is my example. 

 

From this: 

DIM_COMPLAINT_TYPE
ALL_ALL_PostPaid Service
ALL_CF_Customer Feedback
ALL_INQ_Application
ALL_INQ_AF_Billing
ALL_INQ_CF_Products
ALL_INQ_General Inquiry
ALL_REQ_Billing Enrollment 
ALL_REQ_CF_Sim Concerns
ALL_REQ_CF_Other General Support
ALL_REQ_Payment Update
ALL_REQ_Service Maintenance

 

To this: 

DIM_COMPLAINT_TYPE
PostPaid Service
Customer Feedback
Application
Billing
Products
General Inquiry
Billing Enrollment 
Sim Concerns
Other General Support
Payment Update
Service Maintenance

 

Thank you!

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Try this- 1. Go to Power Query

2. Find Extract under Transform tab-

NikhilKumar_0-1606881042733.png

3. Select Text after delimiter

4. Provide the inputs as below and you can see your desired output in snap below-

NikhilKumar_1-1606881146545.png

 

View solution in original post

5 REPLIES 5
Anonymous
Not applicable

Try this- 1. Go to Power Query

2. Find Extract under Transform tab-

NikhilKumar_0-1606881042733.png

3. Select Text after delimiter

4. Provide the inputs as below and you can see your desired output in snap below-

NikhilKumar_1-1606881146545.png

 

This one worked! Thank you so much! 

amitchandak
Super User
Super User

@icdns , Tried same and created two column and one has what you need ( Check Attached file after signature - Table 4)

Step

 

 Table.TransformColumnTypes(#"Split Column by Delimiter",{{"DIM_COMPLAINT_TYPE.1", type text}, {"DIM_COMPLAINT_TYPE.2", type text}})

 

 

 Complete script

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("XZDRDoIwDEV/ZeHZn0AihgQVJD4RQuZotHF0cysm/L2gQjIf+nJPc9rcuo7iPG/nKYznQmInKnAvVBA1my9M0jYZPJsenEgBuqtUjxVmx7KNrdWoJKOhME/bLWqNdAviyVc40w2KfZDvgcBJLTJ6DujGlZ135eIRO3JG6x6IRcAnZ4W9SAwpcOT/2Ynv0/PLgWqw1jgOlgo5fqwX20mGAP36EAeJxECS5m6aNw==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [DIM_COMPLAINT_TYPE = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"DIM_COMPLAINT_TYPE", type text}}),
    #"Split Column by Delimiter" = Table.SplitColumn(#"Changed Type", "DIM_COMPLAINT_TYPE", Splitter.SplitTextByEachDelimiter({"_"}, QuoteStyle.Csv, true), {"DIM_COMPLAINT_TYPE.1", "DIM_COMPLAINT_TYPE.2"}),
    #"Changed Type1" = Table.TransformColumnTypes(#"Split Column by Delimiter",{{"DIM_COMPLAINT_TYPE.1", type text}, {"DIM_COMPLAINT_TYPE.2", type text}})
in
    #"Changed Type1"

 

amitchandak
Super User
Super User

@icdns , In power Query, try Split by delimiter on the right click of the column.  Try with "_" and right most option

 

Split By Delimiter.png

 

 

https://www.tutorialgateway.org/how-to-split-columns-in-power-bi/

Hi @amitchandak 

 

It worked! But there are words with no "_" are affected. 😞 

 

icdns_0-1606880513309.png

 

Thank you!

 

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.