Replace function in query editor | Community
Skip to main content
malter68240968
Level 2
December 2, 2019
Solved

Replace function in query editor

  • December 2, 2019
  • 3 replies
  • 5598 views

Hi,

i would like to replace the first two characters (value is always '33') of a text field with the value '0'. I tried the replace function with a left function inside -> Replace(Field, Left(Field, 2), '0') and i also tried it with a substring function -> Replace(Field (Substring(Field, 1, 2)),'0'). The first case throws an error, the second one works, but it does replace all '33' values in the field and i need it to replace only the first two characters.

Thank you so much in advance for helping out or sharing your ideas on this.

Regards,

Malte

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by prasannakumarmarru

I think this should work-

'0'+Substring(field, 3, dataLength(field)-2)

Thanks!

3 replies

prasannakumarmarru
prasannakumarmarruAccepted solution
Level 4
December 2, 2019

I think this should work-

'0'+Substring(field, 3, dataLength(field)-2)

Thanks!

malter68240968
Level 2
December 4, 2019

Hi,

thank you for helping, but i think i was not expressing myself clear enough, sorry. I only would like to replace the first two characters, if the value is '33' as condition. Would that work as a part of a case when function?

Thank you!

malter68240968
Level 2
December 4, 2019

And what does the datalenght function do with datalenght(field)-2. Does it produce all the characters of the field minus the first two of them?

Thank you