Expand my Community achievements bar.

Is it possible to typecast the datatype in profile query language?

Avatar

Level 3

Documentation do not cover typecasting the data for primitive types (double to integer)

https://experienceleague.adobe.com/docs/experience-platform/segmentation/pql/arithmetic-functions.ht...

 

Can we typecast the profile data in PQL API query approach?

 

For example: Let's say profile has an attribute 'memberShipDuration': '500' , it is a string type. Now in profile query API, would like to convert it to integer so we can divide by 12 to find the number of years.

 

profile.memberShipDuration/12 = 41

2 Replies

Avatar

Employee

Hi @ShashiCh ,

PQL does not offer a cast operator like toInteger currently.

The best way to get the operator working is to add a new field of integer datatype to the schema and populate the dataset with relevant integer values. Then perform the arithmetic operation on this newly added field.

Thanks!

Avatar

Administrator

@ShashiCh Did you find the suggested solutions helpful? It would be great if you can  mark the answer as correct for posterity. If you have found out solution yourself, share it with wider audience in the community.