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

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes! Register now.

Reply
Anonymous
Not applicable

replacing value in a table such as <5 to make it 5, then convert to number and half it

so i have a set of data with loads of <x values , i would like to get rid of the "<" part of the text and leave the number , and with the numbers thatt previously contained a "<" i would like to divide that number by 2

1 ACCEPTED SOLUTION

@Anonymous got it, here is query, just create blank query and in advanced editor paste this code, change it as per your need

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlWK1YlWMgSTYCKm1MDAONkEIYDENMPKhOhAEjBWio0FAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Col = _t]),
    #"Filtered Rows" = Table.SelectRows(Source, each ([Col] <> "")),
    #"Duplicated Column" = Table.DuplicateColumn(#"Filtered Rows", "Col", "Col - Copy"),
    #"Replaced Value" = Table.ReplaceValue(#"Duplicated Column","<","",Replacer.ReplaceText,{"Col - Copy"}),
    #"Changed Type" = Table.TransformColumnTypes(#"Replaced Value",{{"Col - Copy", type number}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each if Text.Contains([Col],"<") then [#"Col - Copy"] / 2 else [#"Col - Copy"]),
    #"Removed Columns" = Table.RemoveColumns(#"Added Custom",{"Col", "Col - Copy"})
in
    #"Removed Columns"


Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

View solution in original post

3 REPLIES 3
parry2k
Super User
Super User

@Anonymous in query editor, use replace feature to replace < with "" and then convert your column to  number field. Add another custom field and divide your original number field with 2.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Anonymous
Not applicable

the problem is that the number column contains values such as

5

1

<4

4

6

6

<6

3

i only want to delete the "<"  and half the numbers that prevously contained "<" and leave the values that didnt contain the "<" alone

@Anonymous got it, here is query, just create blank query and in advanced editor paste this code, change it as per your need

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlWK1YlWMgSTYCKm1MDAONkEIYDENMPKhOhAEjBWio0FAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Col = _t]),
    #"Filtered Rows" = Table.SelectRows(Source, each ([Col] <> "")),
    #"Duplicated Column" = Table.DuplicateColumn(#"Filtered Rows", "Col", "Col - Copy"),
    #"Replaced Value" = Table.ReplaceValue(#"Duplicated Column","<","",Replacer.ReplaceText,{"Col - Copy"}),
    #"Changed Type" = Table.TransformColumnTypes(#"Replaced Value",{{"Col - Copy", type number}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each if Text.Contains([Col],"<") then [#"Col - Copy"] / 2 else [#"Col - Copy"]),
    #"Removed Columns" = Table.RemoveColumns(#"Added Custom",{"Col", "Col - Copy"})
in
    #"Removed Columns"


Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors