Normally the macro functions are written for functionaliy external to qlikview. For example to encypty or forecasting with custom algorithm etc. Your requirment is internal to qlikview; I mean to make calculation using Qlikviews data model. This can be done with qlikview functions.
If you are looking for reusablity of this there is a workaround. Create a variable and which can do the dynamic computation.
Hope this helps,
Yes i am looking for reusabilty of function.
My data is in below format:
Policy_NO Date1 Date2
1 2011-10-15 2011-10-25
2 2011-10-17 2011-10-28
Now for each row I will pass date1 and date2 in a function which will check these dates in another loaded table and will return the count of date falling between these two dates.
So my main requirement is creation of such a function which will perform the above task.
Rather than creating a function if there is any other way then plz do let me know.
Maybe you don't even need a function to fulfill your requirement, an object expression might do just fine.
Could you describe a bit more what the context is, where do you want to do the count (in script or in a chart object), and how those two tables are linked (by Policy_NO ?).
For example, if you have linked the two tables by Policy_NO and use this field as dimension in a table chart, you could maybe use something like
= count( if( Date1 <= Date3 and Date3 <=Date2, Date3))
where Date3 is the date you want to check in the other table. You could probably replace above expression with a set expression also.
Anyway, it would be easier to help you creating a function or expression or script snippet, if you could precise your setting and requirement.
So maybe you could achieve this with interval match and something along this:
LOAD * INLINE [
LOAD * INLINE [
Policy_NO , Date1 , Date2
1, 2011-10-15 , 2011-10-25
2 , 2011-10-17 , 2011-10-28
NOCONCATENATE LOAD * resident Policies;
inner join(tmpPolicies) Intervalmatch (Dates) LOAD Date1, Date2 resident tmpPolicies;
left join (Policies) LOAD
count(Dates),Policy_NO resident tmpPolicies group by Policy_NO;
drop table tmpPolicies;