Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

How to convert GUID to int !!!

Hi guys,

i want to use Peek function to get a value of a specific row but the IDs of field is not a type of integer ,it is a type of uniqueidentifier like

00000000-0000-0000-0000-000000000001

so i want to convert this id to number of type int like :   00000000-0000-0000-0000-000000000001  ==>  1

please can help me to do that .

stalwar1

swuehl

jvs

21 Replies
swuehl
MVP
MVP

Recno() is a Qlik function, not a SQL function.

You can use a preceding LOAD:

LOAD *,

          Recno() as RecID;

SQL SELECT GUID, ...

FROM ....;

Quy_Nguyen
Specialist
Specialist

Hi,

Please try this: Replace(Ltrim(Replace(KeepChar('0000-0000-000000000001', '0123456789'),0,' ')),' ',0)

It will convert your GUID to Int.

SunilChauhan
Champion
Champion

example of text to fetch out desired result

mid( '00000000-0000-0000-0000-000000000001',FindOneOf('00000000-0000-0000-0000-000000000001','123456789'),len('00000000-0000-0000-0000-000000000001')-1)

in general

mid( fieldname,FindOneOf( fieldname,'123456789'),len( fieldname)-1)

Sunil Chauhan
Quy_Nguyen
Specialist
Specialist

Sorry for my ignorance. GUID is 128 bit-integer and it contains not only numbers but also letters. So we  can not use the above approach.

Anonymous
Not applicable
Author

Hi Mr. sunil

I tried your way but i got the same GUID value

it was "{00000000-0000-0000-0000-000000000001}" and got "00000000-0000-0000-0000-000000000001)"

rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

I'll jump in although I'm not sure any of us understand what you are actually trying to do

Lookup('targetField', 'ID', ID, 'targetTable)

-Rob

SunilChauhan
Champion
Champion

using this , i getting  1 as a result.

Take below expression in text box

=mid( '00000000-0000-0000-0000-000000000001',FindOneOf('00000000-0000-0000-0000-000000000001','123456789'),len('00000000-0000-0000-0000-000000000001')-1) 


here i am taking '00000000-0000-0000-0000-000000000001' as Example screen which


you can use this for genralized


use below in script

mid( fieldname,FindOneOf( fieldname,'123456789'),len( fieldname)-1) as Newfieldname ///try this in script


and see the result in Newfieldname at front end

Sunil Chauhan
Anonymous
Not applicable
Author

Maybe my explanation was not clear

i have this table :

111.png

If i want to get the fourth value in the Name field which is BattlePlace i should use Peek function,

but in order to use peek function in such form : let vYourRow= Peek('NewField',Position(numeric), 'table');

i need numeric value but my ID field is not numeric it is GUID and i do not  want to generate a new numric field using Recno()  so how can i solve this issue to use Peek function.

swuehl

stalwar1

omarbensalem

@rob_wunderlich

swuehl
MVP
MVP

If you know you want to query the fourth record in your table, just input 4:

Peek('NewField',4, 'table');

Anonymous
Not applicable
Author

Hi Mr. Stefan

due to some processes in my script i can not know the value (4), i have only GUID value which is 00000000-0000-0000-0000-00000000004.