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

Announcements
Qlik GA: Multivariate Time Series in Qlik Predict: Get Details
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

strange behaviour with right function in load script

hello,

i have an issue in scripting using right function on my values always return negative sign -

My code is

[Code]LOAD @1 as %Key1,

@2 as %Key2,

@3 & '_' & @4 as %Key3,

@3 as %Key4,

@4 as %Key5,

if(index(@5,'-') <> 0 , 0-left(@5,len(@5)-1), @5 ) as [Value In Local Currency not bugged],

if(right(@6,1) = '-' , 0-left(@5,len(@5)-1), @5 ) as [Value In Group Currency bugged ]

FROM .\OHUB_YDCVARHIS_test.CSV (ansi, txt, delimiter is ';', no labels, msq);[/Code]

when i process my file :

9320;01000100;A2;00;716670.00;716670.00;716670.00;716670.00;EUR;EUR;2009003;K4

the result is always negative when i'm using the second formula 😞

Did i do something wrong ? or is this a known bug ?

thx for your replies

10 Replies
Not applicable
Author

I would replace the left(@5,len(@5)-1) syntax by NUM#(left(@5,len(@5)-1)) because you could have some strnage behavior ...

Not applicable
Author

so it means thatt i have to stop using right(...,1) ?

Annette_Steinrücken
Former Employee
Former Employee

Hi,

you can use right, but to be sure to clean the string use trim() function

BR, Annette

Not applicable
Author

Thank you for the proposal, i tried but with no success 😞

if(right(trim(@5),1) = '-' , 0-left(@5,len(@5)-1), @5 )


Best regards

Philippe



Annette_Steinrücken
Former Employee
Former Employee

Hi,

is it possible to post the application?

BR, Annette

Not applicable
Author

here it is

Annette_Steinrücken
Former Employee
Former Employee

QV interprets the value in @5 as a number though your setting is a leading '-'.
That's why the right function does not work here. the number is -1420.76 in QV and has no '-' following.

Regards, Annette

Not applicable
Author

the first line is not the problem, look at the second one, the figure is positive nevertheless Qlikview show it as a negative one

regards

Annette_Steinrücken
Former Employee
Former Employee

Yes, I understand.

The problem is that QV interprets @5 as a number. Even if you try to force QV to take it as a string with text()
Obviously there is a difference between left and right.