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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Jamieneedshelp
Frequent Visitor

Keep text between 2 deliminators- kind of!

Hi All

 

When importing termstore data to power bi we get lots of unwanted text. Is there any way to just keep Oranges and Apples from the below and remove the rest?

 

[{"Label":"Oranges","TermID":3fij4h4jkdkddjdj4ndjdke3"},{"Label":"Apples","TermID":3fij4h4jkdkddjdj4ndjdke3"}]
 
So something like keep text between [{"Label":  and ,"TermID": so desired result would just be Oranges, Apples
 
Many Thanks
 
1 ACCEPTED SOLUTION
Vijay_A_Verma
Super User
Super User

Use the below formula in a custom column (here Text is your column name which you will need to change)

Text.Combine(List.Transform(Text.Split([Text], "},{"), (x)=> Text.Trim(Text.BetweenDelimiters(x, """Label"":", ",""TermID""" ), """")), ", ")

View solution in original post

6 REPLIES 6
Jamieneedshelp
Frequent Visitor

Thanks all will try these suggestions as see if they work 😁👍

Anonymous
Not applicable

I would first replace all of the quotes with "~" or any character not appearing in the text, to avoid any text-quote issues. Then you can use Text.BetweenDelimiters, using ":~" and "~,".

 

--Nate

Vijay_A_Verma
Super User
Super User

Use the below formula in a custom column (here Text is your column name which you will need to change)

Text.Combine(List.Transform(Text.Split([Text], "},{"), (x)=> Text.Trim(Text.BetweenDelimiters(x, """Label"":", ",""TermID""" ), """")), ", ")
Greg_Deckler
Community Champion
Community Champion

@Jamieneedshelp This is hacky:

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45Wiq6OUfJJTErNiVGyilHyL0rMS08tjlHSiVEKSS3K9XQBChunZWaZZJhkZadkp6RkpWSZ5AHJ7FTjGKVaHRTdjgUFOSRojlWKjQUA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Column1 = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Column1", type text}}),
    #"Split Column by Delimiter" = Table.SplitColumn(#"Changed Type", "Column1", Splitter.SplitTextByDelimiter(",""TermID"":", QuoteStyle.None), {"Column1.1", "Column1.2"}),
    #"Changed Type1" = Table.TransformColumnTypes(#"Split Column by Delimiter",{{"Column1.1", type text}, {"Column1.2", type text}}),
    #"Split Column by Delimiter1" = Table.SplitColumn(#"Changed Type1", "Column1.2", Splitter.SplitTextByDelimiter(",{""Label"":", QuoteStyle.None), {"Column1.2.1", "Column1.2.2"}),
    #"Changed Type2" = Table.TransformColumnTypes(#"Split Column by Delimiter1",{{"Column1.2.1", type text}, {"Column1.2.2", type text}}),
    #"Removed Columns" = Table.RemoveColumns(#"Changed Type2",{"Column1.2.1"}),
    #"Replaced Value" = Table.ReplaceValue(#"Removed Columns","[{""Label"":","",Replacer.ReplaceText,{"Column1.1"}),
    #"Replaced Value1" = Table.ReplaceValue(#"Replaced Value","""","",Replacer.ReplaceText,{"Column1.1", "Column1.2.2"}),
    #"Merged Columns" = Table.CombineColumns(#"Replaced Value1",{"Column1.1", "Column1.2.2"},Combiner.CombineTextByDelimiter(",", QuoteStyle.None),"Merged")
in
    #"Merged Columns"


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

So basically, Greg just M coded what I wrote in plain text. 😁 

 

Problem solved. 🎉


Did I answer your question? Mark my post as a solution!super-user-logo

Proud to be a Super User!


rubayatyasmin
Super User
Super User

Hi @Jamieneedshelp 

 

Try splitting it into two cols first then you should have terms and labels column. In label column perform power query transformation, split by delimeter. As delimeter select :" this way you will get Oranges, apples in another column. Remove the other redundant columns as you finish. 

 

If it's hard to understand provide me some demo data I will upload a pbix for you. 

 

Thanks


Did I answer your question? Mark my post as a solution!super-user-logo

Proud to be a Super User!


Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors