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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
I_ia
Frequent Visitor

Delete a group of numbers

Hi,

 

How can I delete a group of numbers. For example, the red ones (they are always like that 7 numbers - 1 number)

I_ia_3-1661344255872.png

 

should be like this:

I_ia_1-1661344141277.png

 

 

1 ACCEPTED SOLUTION
BA_Pete
Super User
Super User

Hi @I_ia ,

 

Create a new blank query and paste the following code over the default code in Advanced Editor:

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("Hcs7DgMhDEXRrTxRB2mwgZl1pEqEKCgoLBSQYk8xu8+nvTq3FBdxvcUuBcUtBiLPrt6Ke/7i0G7gcBw7s8/wuHc1PP4gY4hM66K2YNLn67TRwHFDSJQpJb9/DzuXtTmXanO1fgA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [textColumn = _t]),
    addSplitList = Table.AddColumn(Source, "splitList", each Text.Split([textColumn], " ")),
    addReplaceList = Table.AddColumn(addSplitList, "replaceList", each List.Transform([splitList], each if Text.Contains(_, "-") and Text.Length(_) = 9 then null else _)),
    addCombineList = Table.AddColumn(addReplaceList, "combineList", each Text.Combine([replaceList], " ")),
    remOthCols = Table.SelectColumns(addCombineList,{"textColumn", "combineList"})
in
    remOthCols

 

I've left the steps separate so it'd easier to follow what's going on, but this could easily be written into a single step.

This gives me the following ouput:

BA_Pete_0-1661424356501.png

 

Pete



Now accepting Kudos! If my post helped you, why not give it a thumbs-up?

Proud to be a Datanaut!




View solution in original post

3 REPLIES 3
wdx223_Daniel
Super User
Super User

just for the sample data

= Table.AddColumn(PreviousStepName,"Custom",each Text.Combine(List.RemoveMatchingItems(Text.Split([textColumn]," "),{true},each if _ is logical then _ else Text.Length(_)=9 and Text.Remove(_,{"0".."9"})="-" and Text.At(_,7)="-")," "))

BA_Pete
Super User
Super User

Hi @I_ia ,

 

Create a new blank query and paste the following code over the default code in Advanced Editor:

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("Hcs7DgMhDEXRrTxRB2mwgZl1pEqEKCgoLBSQYk8xu8+nvTq3FBdxvcUuBcUtBiLPrt6Ke/7i0G7gcBw7s8/wuHc1PP4gY4hM66K2YNLn67TRwHFDSJQpJb9/DzuXtTmXanO1fgA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [textColumn = _t]),
    addSplitList = Table.AddColumn(Source, "splitList", each Text.Split([textColumn], " ")),
    addReplaceList = Table.AddColumn(addSplitList, "replaceList", each List.Transform([splitList], each if Text.Contains(_, "-") and Text.Length(_) = 9 then null else _)),
    addCombineList = Table.AddColumn(addReplaceList, "combineList", each Text.Combine([replaceList], " ")),
    remOthCols = Table.SelectColumns(addCombineList,{"textColumn", "combineList"})
in
    remOthCols

 

I've left the steps separate so it'd easier to follow what's going on, but this could easily be written into a single step.

This gives me the following ouput:

BA_Pete_0-1661424356501.png

 

Pete



Now accepting Kudos! If my post helped you, why not give it a thumbs-up?

Proud to be a Datanaut!




I_ia
Frequent Visitor

 

Hi, thanks, this was the perfect solution to my problem. Many thanks to you!!

Helpful resources

Announcements
PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

Top Solution Authors
Top Kudoed Authors