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

1 Solution

Accepted Solutions
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

View solution in original post

21 Replies
swuehl
MVP
MVP

Not sure why you want to use the Peek() function or what your final result should be.

It would be good to see a sample of input data and an expected result table.

To convert a text value (that's how I see your GUID, right?) into a number, you can for example use one of the Autonumber() or AutonumberHashXXX() functions.

autonumber - script function ‒ Qlik Sense

OmarBenSalem

table:

load num( right(YourField, 1) )as NewField

from source;

let vYourRow= Peek('NewField',Position(numeric), 'table'); //exp : let vYourRow= Peek('NewField',0, 'table');

sunny_talwar

‌Are you just looking to get a numeric value from your GUID? If that is what you want, then may be you need to use KeepChar()... or PurgeChar()

KeepChar(FieldName, ‘0123456789’) * 1

Anonymous
Not applicable
Author

Hi Mr.Stefan

i want to know the position of the raw which i want to peek value from ,since the ID field is GUID and i tried to pass it to Peek function but the result was NULL. so i want to convert GUID to int to pass it to Peek function

Anonymous
Not applicable
Author

Hi Mr.Sunny

what i want to do is to get the specific value of the specific field but in order to use peek function i have to pass the index of the row where the value exist but the ID Field of my table is GUID like 00000000-0000-0000-0000-000000000001 not int like 2,3,4 so i want to convert this GUID to number in order to pass it to Peek fucntion.

Anonymous
Not applicable
Author

Hi Mr. Stefan

what i want to do is to get the specific value of the specific field but in order to use peek function i have to pass the index of the row where the value exist but the ID Field of my table is GUID like 00000000-0000-0000-0000-000000000001 not int like 2,3,4 so i want to convert this GUID to number in order to pass it to Peek fucntion.

sunny_talwar

‌Don’t think I understand what you are after. Can you explain with more example data points?

swuehl
MVP
MVP

Not sure I understand your request.

Maybe create a row number in your load by using Recno() or RowNo() functions when loading the table:

Counters in the Load

Table:

LOAD

     Recno() as RecID,

     GUID,

     OtherField,

     AnotherField,

     ...

FROM ...;

Or use Lookup() function to pass a field value (GUID) as search value in your table search and to retrieve another field value in the same row.

LookUp - script function ‒ Qlik Sense

Anonymous
Not applicable
Author

yes that what i want

my problem will be solved by using Recno() but my data coming from SQL server and i tried to write :

select Recno() as RecID,GUID,... from my table after opening connection but there is an runtime error