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

Announcements
Join us to spark ideas for how to put the latest capabilities into action. Register here!
cancel
Showing results for 
Search instead for 
Did you mean: 
paul_ripley
Creator III
Creator 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

Labels (1)
1 Solution

Accepted Solutions
paul_ripley
Creator III
Creator III
Author

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
JGMDataAnalysis
Creator III
Creator III

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

 

 

paul_ripley
Creator III
Creator III
Author

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