Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
farolito20
Contributor III
Contributor III

Return Function

How can I return a value from a function?

1 Solution

Accepted Solutions
flipside
Partner - Specialist II
Partner - Specialist II

This might work ...

Let v = functionName(value);

... or you can do row-level function changes using ...

Data:

Load

     field,

     functionName(field) as newField

...

flipside

View solution in original post

5 Replies
khadeer
Specialist
Specialist

for getting most repeated value we can use mode(value)..

I think ur question is nt clear

farolito20
Contributor III
Contributor III
Author

I need something like this. This isn't correct but that's the idea

Function fnConvTooQQ(uniBase,cantBase){

          var cantReturn;

          var factConv;

          if (uniBase=="LTA" || uniBase=="FGS" || uniBase=="QQ"){

                    cantReturn=cantBase;

          }

          else {

                    factConv = "LOAD FC as factConv FROM vConversionUM.qvd (qvd) WHERE UMO = uniBase and UMD='QQ'";

                    cantReturn = cantBase * factConv;                    

          }

          return cantReturn;

};

flipside
Partner - Specialist II
Partner - Specialist II

This might work ...

Let v = functionName(value);

... or you can do row-level function changes using ...

Data:

Load

     field,

     functionName(field) as newField

...

flipside

farolito20
Contributor III
Contributor III
Author

But if I have this code in a sub.. end sub, I can't return a value?

flipside
Partner - Specialist II
Partner - Specialist II

Yes, I think so.  The name of the sub causes an error in QV script editor, whereas a function even prompts you for the number of parameters required.

You can define a subroutine earlier in the load script and call it using the CALL command - see QV help - but this is a QV sub not a module sub.

flipside