Qlik Community

QlikView App Development

Discussion Board for collaboration related to QlikView App Development.

Announcements
Save the Date: QlikWorld Online, June 24-25, 2020. Free global virtual event for data integration and data analytic gurus. Register Today
Contributor III

How to use a variable in a calculated dimension with an IF statement

Hello

I have a variable vQuoted.  It contain the values '02502028','22001206'

I'd like to use a calculated dimension and have done the below. Portfolio is another dimension

The below gives an error 

=if(portfolio = $(vQuoted),'Quoted','Unquoted')

I did also try the below which didnt give an error but it doesnt calculate the variables

=if(portfolio = vQuoted,'Quoted','Unquoted')

 

Can you please help

Paul

1 Solution

Accepted Solutions
Highlighted
Contributor III

Re: How to use a variable in a calculated dimension with an IF statement

Thanks for your help

I dont really understand the inline thing but i did think the idea of doing in the script was good, so i created a new dimension and that worked

if(match(portfolio,'02502028', '22001206')>=1, 'Quoted','Unquoted') as portfolio_quoted,

 

Thanks for your help

View solution in original post

2 Replies
Highlighted
Contributor II

Re: How to use a variable in a calculated dimension with an IF statement

You can solve this at load time (script)...

SET vQuoted = 02502028, 22001206;

Test:
NOCONCATENATE 
LOAD *, If(Index('$(vQuoted)', Portfolio), 'Quoted', 'Unquoted') AS Dim
INLINE [
        Portfolio,
        02502028
        22001206
        22001207
];

 

Use Dim field (From Script). Otherwise, add calculated dimension (FRONTEND).

clipboard_image_0.png

 

 

Highlighted
Contributor III

Re: How to use a variable in a calculated dimension with an IF statement

Thanks for your help

I dont really understand the inline thing but i did think the idea of doing in the script was good, so i created a new dimension and that worked

if(match(portfolio,'02502028', '22001206')>=1, 'Quoted','Unquoted') as portfolio_quoted,

 

Thanks for your help

View solution in original post