Qlik Community

QlikView App Development

Discussion Board for collaboration related to QlikView App Development.

Announcements
Leverage your QlikView investment to modernize BI – see how! Join Group
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Anonymous
Not applicable

Macro in expression

Hi,

I made a macro to calculate the delay working days between two dates and I'd like to use it inside a chart expression...something like that:

Sum(If(ArrivalData>=DueDate,GetWorkDays (ArrivalDate, DueDate),0))/Count(NumberOfDocuments)

But the expression give me a syntax error, maybe due to the use of the macro into the expression...is that true? Is there a workaround for the problem?

Thanks.

N.

5 Replies
Highlighted

Re: Macro in expression

You can define a variable in which you repeat the logic of your macro, then use variable in expression

Highlighted
Creator
Creator

Re: Macro in expression

I did not understand the purpose to create a macro in such situation. Normally, either we create variable, or a temporary column .

If you must do something like this in chart, then you can create expressions in the chart,

first expression:

ArrivalData-DueDate

Secondexpression: Sum(If(column(1)>0, GetWorkDays (ArrivalDate, DueDate),0))/Count(NumberOfDocuments)

Something like this should help

Highlighted
Anonymous
Not applicable

Re: Macro in expression

Well, the macro is this:

Function GetWorkDays(StartDate, EndDate)

    dCount = 0

    For dt = StartDate To EndDate

        If WeekDay(dt) <> 1 Then

            dCount = dCount + 1

        End If

    Next

    GetWorkDays = dCount

End Function

Should someone explain to me how can I transform it in a varialble?

Thks

N.

Highlighted

Re: Macro in expression

Probably you need networkingdate() function instead of the variable

Highlighted
Anonymous
Not applicable

Re: Macro in expression

The NetWorkDays() Function considers the work days from Mon to Fri, contrariwise I've to consider Sat as a workable day.

This is the reason I've made the macro.

Thks.