Skip to main content

QlikView App Dev

Discussion Board for collaboration related to QlikView App Development.

Announcements
QlikWorld 2023, a live, in-person thrill ride. Save $300 before February 6: REGISTER NOW!
cancel
Showing results for 
Search instead for 
Did you mean: 
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
alexandros17
Partner - Champion III
Partner - Champion III

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

thisisnita
Creator
Creator

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

Anonymous
Not applicable
Author

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.

alexandros17
Partner - Champion III
Partner - Champion III

Probably you need networkingdate() function instead of the variable

Anonymous
Not applicable
Author

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.