Discussion Board for collaboration related to QlikView App Development.
Hi All, Thanks for your time,
I have a load statement something like below
CBDI_DATA:
LOAD
UPPER(TRIM(Short_Server_Name)) AS ShrtServerName
FROM A FILE;
>>
EXAMPLE OF VALUES IN ShrtServerName FROM THE ABOVE LOAD ARE DEV,UAT,PROD,TEST,SAND ETC
>>
IF THE VALUE IN ShrtServerName is DEV THEN I want to do the concatenate like below with a space after the beginning of the first star and a space before the 2nd star something like * DEV * - else part would be same but without spaces
this is giving an error as invalid expression - any suggestions
CBDI_DATA_CONDTION1:
LOAD
if(ShrtServerName= 'DEV', Concat(chr(39) &'*'& ShrtServerName &'*' & chr(39), ',') ,'NO' ) AS ShrtDerived
RESIDENT CBDI_DATA;
DROP TABLE CBDI_DATA;
Any error you are facing with this expression ?
invalid expression is the error message for some reason it does not like the IF condition in it if I take out the IF condition the concat works fine
Can you please share some sample app and expected output.
HI PM
thanks for your time, attached sample qvw file
Concat() is an aggregation function and it requires a group by clause if any fields are referenced outside of aggregation functions...
This line makes no syntactic sense.
if(ShrtServerName= 'DEV', Concat(chr(39) &'*'& ShrtServerName &'*' & chr(39), ',') ,'NO' )
What are you concatenating?
Thank you Jonathan,
The reason I was using an IF condition is I want to check for the value DEV as the concat is different for this
IF(ShrtServerName = 'DEV' THEN
Concat(chr(39) &'* '& ShrtServerName &' *' & chr(39), ',')
ELSE
Concat(chr(39) &'*'& ShrtServerName &'*' & chr(39), ',')
AS DerivedSName
I remember reading concat is an aggregation function - thanks a lot - let me use this with a group by
Thanks again
Hello qvraj123,
You don't even need the Concat function in the script. Just using standard 'concatenation' string operations with '&'. See example below:
CBDI_DATA:
LOAD * Inline [
ShrtServerName
DEV
UAT
PROD
TEST
SAND
];
CBDI_DATA_CONDTION1:
LOAD
ShrtServerName,
IF(ShrtServerName= 'DEV',
'* ' & ShrtServerName & ' *', // with spaces for DEV server name
'*' & ShrtServerName & '*') as ShrtDerived // without spaces
RESIDENT CBDI_DATA;
DROP TABLE CBDI_DATA;
The output of this script is:
I believe this was the behavior you were trying to achieve.
Hope it helps you.
Regards,
i have to get these values like '* DEV *', '*UAT*' ETC and store them into a variable since I will be using this variable later in a wildmatch like wildmatch(Myfield, vVariable1) - that's the reason for including the single quotes for each word
Thanks a lot
Thank you Jonathan, this worked with the group by