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

Trimming unwanted '%' from raw data

I've got dozens of raw files I load each day (see attachment). I've got a script (attached) that processes these in to QVD format. I've got a field in the raw data called Capacity that shows the figure as a percentage (i.e. 25%). I want to trim the '%' sign from this field whenever it occurs. I don't simply want to trim the last character in case it's not a %, so the script must specifically trim '%' signs only from this field. What's the best way to achieve this?

1 Solution

Accepted Solutions
Anonymous
Not applicable

Try the PurgeChar() function.

View solution in original post

6 Replies
Anonymous
Not applicable

Try the PurgeChar() function.

alexandros17
Partner - Champion III
Partner - Champion III

The easiest way is, when you load you file (es. gbl05928_filesystem.Sep_04_2014) to do:

Load

...

PurgeChar(Capacity, '%') as capacity

from

...


Let me know

peterwh
Creator II
Creator II

Hi Shane,

I would simpy do an "replace(Capacity, '%', '') AS Capacity". Maybe this helps already

Kind regards

Peter

shane_spencer
Specialist
Specialist
Author

That's perfect - assumed there would be an easy answer, it's just about knowing what that answer is.

PurgeChar(Capacity, '%') as Capacity%

Anonymous
Not applicable

Yup - It's all there in the QV Desktop Help, but as always the Catch 22 is that it is only easy to find as long as you already know the answer.

shane_spencer
Specialist
Specialist
Author

Thank you Peter Hübschen the "replace" function came in very handy for updating the last 7 months worth of processed data in 1 easy swoop! i.e.

LOAD Date,

    Server,

    Hour,

    Minute,

    Main_metric,

    replace(sub_Metric, 'Capacity', 'Capacity%') AS sub_Metric ,

    replace(value, '%', '') AS value