Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Does anyone know how to split out a field? ... For example, I have a field "description" which can be like MediumNASize4ColorYellow ... I only want to see characters 3-19... so "diumNASize4ColorYel"
What is the most optimal way to do this?
The mid() function is the QV substring - select characters based on position. If it's always 3-19 you want, it's a as simple as
mid(myfied,3,16) as newFiled
-Rob
The subfield function is useful in these situations, but you'll need a delimiter to separate the string on. For instance, if you wanted to break 'Size4' out of the string this would work:
=subfield(Subfield(Description,'A',2),'C',1)
But this is assuming that every record in the field is formatted as in your example. If you don't mind me asking, why do you want to separate 'diumNASize4ColorYel', it doesn't seem to be a useful piece of in the string.
Otherwise, if you have to separate on the between the 3 and 19 index of the string I'm not sure how to help. I can't find any functions that allow you to slice a string like that. Hopefully someone else will know.
Matt
You may also find these resources helpful:
QlikView App: Split Values from a String and ApplyMap to Results
http://community.qlik.com/blogs/qlikviewdesignblog/2013/03/28/string-functions
The mid() function is the QV substring - select characters based on position. If it's always 3-19 you want, it's a as simple as
mid(myfied,3,16) as newFiled
-Rob
Hi,
Try this in load script, it is optimal one so there is no need to do it in front end every time.
TableName:
LOAD
*,
Mid('MediumNASize4ColorYellow', 3, 16) AS FieldName
FROM DataSource;
Now used FieldName as required.
Regards,
Jagan.
Hi,
If the character length is differ in each row and you want to extract specific character, for example, if you want to extract "Color" from character, you may try below,
Mid('MediumNASize4ColorYellow', Index('MediumNASize4ColorYellow', 'Color'), 5)
Thanks everyone for the responses. Right now, the "Mid(Field, 3,16) as NewField" works but I would prefer for it to be done in the script so that I don't have to use an expression in the chart or table box to show the description.
Jagan's response would work if all the values in "Description" field were the same..but the data looks like the one below where each description is different. Is there any other way to do this in the script? Is there another way to set up the mid function?
Description
- MediumNASize4ColorYellow
- SmallNASize2ColorBlue
- LargeNASize0ColorRed
Your help is much appreciated.
For each different description text, the same characters from 3 to 19 will be needed, no specific characters. Always the same
Hi,
Try this in load script, it is optimal one so there is no need to do it in front end every time.
TableName:
LOAD
*,
Mid(Description, 3) AS FieldName
FROM DataSource;
Now used FieldName as required.
Regards,
Jagan.
Mid(FieldName,3,16)
3=starting index of strign
16=number of characters you want to extract from string