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

Announcements
See why IDC MarketScape names Qlik a 2025 Leader! Read more
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Creating custom functions with variables in Qlikview

Hi All,

I want to write a function that calculates a date based on 2 variables.

In VBA, I'll have:

Function GetDate(i as date, j as string)

GetDate = if(j = "NE", date(2015,1,1),

                         if( date(year(i), month(i), day(i)) < date(2014,1,1) , date(year(i), month(i), day(i)), date(2014,1,1)))

End function

Then I'll call the function in VB as:

SELECT X as Name,

          .....GetDate(Birthdate, City), ..

......

My question is how to translate the same function above in Qlikview. Specifically, my questions are:

     1. How to call the GetDate function in the load script

     2. Where to set the variable type (i as date, j as string).  I experimented in the module editor for Qlikview but somehow using

               function GetDate(i as date, j as string)

     doesn't work..

Thanks for any help any one can give me.

1 Reply
jagan
Partner - Champion III
Partner - Champion III

Hi,

Check this sample file for solution, you can call VB macros in Qlikview scripting

Calling VB function (macro) in Load script to find common string length in two strings

Hope this helps you.

Regards,

jagan.