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

Announcements
Qlik Connect 2026! Turn data into bold moves, April 13 -15: Learn More!
cancel
Showing results for 
Search instead for 
Did you mean: 
AmCh
Creator
Creator

expression to macro

Hi all,

as I have a chart expression that I use often, I would like to convert it into a macro so that I can easily call it when needed.

The chart expression is as follows:

=SUM(round(If(rangemax($(m)*a,$(n)*b,c)=0,0,round(rangemax($(m)*a,$(n)*b,c)*Valueloop(1,$(o))-if(Valueloop(1,$(o))=$(o),0.001,0))*(1-d)+((Valueloop(1,$(o))-1/rangemax($(m)*a,$(n)*b,c))/$(o)+1)*d))*e)+SUM(round(If(rangemax($(m)*a,$(n)*b,c)=0,0,round(rangemax($(m)*a,$(n)*b,c)*Valueloop(1,$(o))-if(Valueloop(1,$(o))=$(o),0.001,0))*(1-d)+((Valueloop(1,$(o))-1/rangemax($(m)*a,$(n)*b,c))/$(o)+1)*d))*f*$(q)

Where m,n,o,q are values entered by the user with the input fields.

where a,b,c,d,e,f are imported fields (e.g. size=5).

What is the equivalent of this expression in scripting as a function?

Thanks in advance

Labels (2)
2 Replies
JustinDallas
Specialist III
Specialist III

You can try storing that into a variable and then evaluating it with SET.

 

I use something like this in my script.

SET vFuelFlatCount = Sum({<[Invoice Detail Charge Type]={'FUELFL'}>}[Invoice Detail Quantity])
;

 

And then in my dashboard, I use something like this for my measure:

$(vFuelFlatCount)
AmCh
Creator
Creator
Author

Thank you for your reply.

I need it but dynamic in order to call it in chart expression and just to modify my parameters (parameters of the defined function).

This expression should look like in module as:

Function calc(parameters)

for

if ... then

..

end if

next

End function

Any help here?