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

Announcements
Join us in NYC Sept 4th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
farolito20
Contributor III
Contributor III

What's wrong?

sub fnConvToQQ(uniBase,cantBase)

          if(match(uniBase,'LTA','FGS','QQ'),cantBase,cantBase*2);

end sub

4 Replies
Not applicable

Hi,

You can't put an if just like that in a subrutine, you need to assign the result to a variable:

let var = if(match(uniBase,'LTA','FGS','QQ'),cantBase,cantBase*2);

uniBase and cantBase are variables or fields? I don't think you can use fields as parameters, they have to be variables

Regards!

farolito20
Contributor III
Contributor III
Author

Yes, are fields.

And if I need do somethind like this:

let factConv = (load FC FROM vConversion WHERE UMO=uniBase and UMD='QQ);

Not applicable

Hi

This depends on what that load statement is going to return.... if you can guarantee that the load statement will return only one row for that command (i.e. there is only one occurrence of uniBase/QQ in the table) then you can use a simple load statement to load into a table then:

LET factConv = PEEK('FC',0,'TableName');

If there are going to be more than one row returned then you need to be more specific about what you want to to create, if it is simply that you want the FC column value to be called factConv then just do:

LOAD FC AS factConv FROM ....................

But I guess this is not what you need, so let us know what that is and we'll try to help.

farolito20
Contributor III
Contributor III
Author

SUB fnConvToQQ(uniBase,cantBase)

          LOAD FC AS factConv FROM vConversionUM WHERE UMO=uniBase and UMD='QQ');

          LET cantReturnQQ = IF(MATCH(uniBase,'LTA','FGS','QQ'),cantBase,cantBase*factConv;

END SUB