Skip to main content
Woohoo! Qlik Community has won “Best in Class Community” in the 2024 Khoros Kudos awards!
Announcements
Nov. 20th, Qlik Insider - Lakehouses: Driving the Future of Data & AI - PICK A SESSION
cancel
Showing results for 
Search instead for 
Did you mean: 
hopkinsc
Partner - Specialist III
Partner - Specialist III

help with subfield

Hi all,

I have a field (@8) which contains user logon names, but they are a mixture of formats. i.e.

NT-DOMAIN\FirstnameLastname

NT-DOMAIN\R_FirstnameLastname

I have used the following to strip out the domain and \ so i just end up with the FirstnameLastname

lower(SubField(@8,'\',2)

this works great for the majority of the logon names but it leaves a few that are :

R_FirstnameLastname.

Can anyone tell me how to also strip out the R_ all in the same expression?

note: R_ is only one, there are other letters too with underscores (so not always R)

Thanks

1 Solution

Accepted Solutions
jerem1234
Specialist II
Specialist II

You can try:

=mid(SubField(@8,'\',2), index(SubField(@8,'\',2), '_')+1)

Hope this helps!

View solution in original post

13 Replies
jonathandienst
Partner - Champion III
Partner - Champion III

Hi

Just nest the subfields, like this:

=SubField(SubField(@8,'\',2) '_', 2)

HTH

Jonathan

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
Not applicable

Hi

why not only

=SubField(@8, '_', 2)   which give FirstnameLastname

best regards

Chris

hopkinsc
Partner - Specialist III
Partner - Specialist III
Author

Thanks Jonathan, but that fails to reload. it says its missing a close bracket, although it looks correct to me.

also, i still need to make the field lower case.

sunilkumarqv
Specialist II
Specialist II

try this

if you want to purge certain character then use below

purgechar ( 'NT-DOMAIN\R_FirstnameLastname','R_' ) returns ''NT-DOMAIN\FirstnameLastname'

or

Trim(Replace(Replace(Replace(SubField(@8, '\', 2), 'R_FirstnameLastname', 'FirstnameLastname'))) AS ColumnField

hopkinsc
Partner - Specialist III
Partner - Specialist III
Author

Hi christian,

that would work if all of the logon names were in the format of

NT-DOMAIN\R_FirstnameLastname.

That doesnt work for the ones in the format of

NT-DOMAIN\FirstnameLastname.

hopkinsc
Partner - Specialist III
Partner - Specialist III
Author

Hi Sunil,

Thanks, but as i said not all are in the format of R_, some are C_, A_ etc.

I thought i could wrap another subfield around my current one like Jonathan suggested, but i can't get it to work

sunilkumarqv
Specialist II
Specialist II

try this

if you want to purge certain character then use below

purgechar ( 'NT-DOMAIN\R_FirstnameLastname','R_' ) returns ''NT-DOMAIN\FirstnameLastname'

or

Trim(Replace(Replace(Replace(SubField(@8, '\', 2), 'R_F', 'F'), 'C_F', 'F'), 'A_', 'F')) AS imex


u may continue in these manner

jerem1234
Specialist II
Specialist II

You can try:

=mid(SubField(@8,'\',2), index(SubField(@8,'\',2), '_')+1)

Hope this helps!

PrashantSangle

Hi,

Try this

=SubField(SubField(@8,'\',2) ,'_', 2)

Great dreamer's dreams never fulfilled, they are always transcended.
Please appreciate our Qlik community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved 🙂