Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
mwscott1
Creator
Creator

Read data from right to left

I have a column of data "file name" that I am trying to read each item from right to left starting at the end and stopping at the first - that it comes to and load it as "serial number". I have used sub-stings before but only going from left to right with a set amount of characters to read. In this case not all serial numbers are the same length.

data example

I just want to return the part in red.

-685922-685922-1FTSA07019.txt
-699509-699509-1CTSA05422.txt
-704002-704002-1DTSA10880.txt
1 Solution

Accepted Solutions
MK_QSL
MVP
MVP

SubField(FileName,'-',-1) as Result

Or

SubField(SubField(FileName,'-',-1),'.',1) as Result

View solution in original post

4 Replies
mwscott1
Creator
Creator
Author

or really just need what is between the - and the .txt

Not applicable

Hi, this can be achieved by using mid function.

= mid('-685922-685922-1FTSA07019.txt', index('-685922-685922-1FTSA07019.txt', '-', -1), (index('-685922-685922-1FTSA07019.txt', '.', -1) - index('-685922-685922-1FTSA07019.txt', '-', -1)) )

Idea is mid (<string>, <index of '-' from right>, <index of '.' from right - index of '-' from right>)

Arun

MK_QSL
MVP
MVP

SubField(FileName,'-',-1) as Result

Or

SubField(SubField(FileName,'-',-1),'.',1) as Result

maxgro
MVP
MVP

'-' & SubField([file name],'-',-1)