28 september 2022 Qlik subroutine parameters – passing arguments by reference and by value Deel dit bericht Every Friday at Bitmetric we’re posting a new Qlik certification practice question to our LinkedIn company page. Last Friday we asked the following Qlik Data Architect certification practice question about passing arguments to Qlik subroutine parameters: This proved to be a harder question than expected, as only a single person got the right answer. Well done Vaibhav Sharma! The correct answer is B: lines 4 and 8 both show the value 8 We’re modifying the parameter called pInput and somehow this also affects the variable vNumber? How is that possible? The explanation is that we passed the argument by reference instead of by value. In short, when we pass by value we provide a copy of the variable, but when we pass by reference we provide the actual variable to the subroutine. Read on to get a more in-depth explanation. Sidebar: argument vs parameterThese terms are often used interchangeably, but they actually do have different meanings. A parameter is the name that is listed in the subroutine definition. In this example that’s pInput. An argument is the value that’s actually supplied. In this example that’s vNumber. How variables are stored in memory To explain the difference between passing by value and passing by reference we first need some basic knowledge of how memory works. We’ll use a simplified explanation for this, which should be enough to understand the basic concept. You can consider memory as a collection of blocks that can hold data. Each block has an address, numbers 1 through 60in the illustration below. When you store a value into a variable, your operating system will automatically decide where to place this in memory. In the illustration below, the value we’ve set for the vNumber variable is stored at memory address 32. Pass by value When we pass by value, the value is copied to another location in memory. In the illustration below a copy of the value is placed at memory address 24. Subsequent operations, such as the multiplication in the subroutine, are performed on the copy. The original value is left untouched. Pass by reference When we pass by reference, we pass a reference to the memory address of the variable. What this means in our example is that both vNumber and vInput now reference the same memory space and value within that space. Any operation that is performed to pInput updates the same value that is being referenced by vNumber, and vice versa. This explains the behavior that we see in the example script. Passing by value vs passing by reference in Qlik So how can we fix this script to ensure that vNumber is passed by value? By using Dollar-sign expansion! This passes the value of the variable to the subroutine, rather than a reference to the variable. See the updated script below, with a change on line 9. That’s it for this week. See you next Friday? More from the Bitmetric team Bitmetric Qlik Support Keep your Qlik environment running smoothly with proactive support that prevents issues before they appear. Available on flexible monthly plans. Learn more. Qlik vs Power BI Series See how Qlik and Power BI perform when theory meets reality. Three apps rebuilt, every step examined. Learn more. Qlik examentraining Script Oplossing Hoe kunnen we je ondersteunen? Barry beschikt over meer dan 20 jaar ervaring als architect, developer, trainer en auteur op het gebied van Data & Analytics. Hij is bereid om je te helpen met al je vragen. Bel ons Mail ons 13 oktober 2026 TimeXtender 20.10 uit support vanaf december 2027: Classic of TDI? TimeXtender stopt in december 2027 met de ondersteuning van versie 20.10. Veel organisaties werken daar nog mee, en zij moeten overstappen naar TimeXtender Classic of naar TimeXtender Data Integration (TDI). Welke route past, hangt vooral af van je huidige omgeving en van je plannen voor de komende jaren. TimeXtender 5 oktober 2026 FabCon Europe 2026: de Fabric-updates die er echt toe doen Copilot gaat nu rechtstreeks aan de slag met je semantic models. Dat klinkt mooi, maar het betekent ook dat elk rommelig model een veel groter publiek krijgt. Wij zetten de FabCon Europe 2026-aankondigingen op een rij die er in de praktijk toe doen: van governance en capacity overage tot nieuwe tools voor data engineers. Plus wat we je nu al zouden aanraden. AI Evenement Microsoft Fabric Power BI 1 september 2026 Qlik Answers-review: wat we leerden van tests in de praktijk We testten Qlik Answers op een echt verkoopmodel in productie om te zien hoe het omgaat met analytics in de praktijk. De resultaten waren veelbelovend, maar voor betrouwbare antwoorden moesten we zorgvuldig werken aan het logische model, mastermetingen, dimensies en de bedrijfscontext. AI Data-analyse Qlik Semantic Layer
13 oktober 2026 TimeXtender 20.10 uit support vanaf december 2027: Classic of TDI? TimeXtender stopt in december 2027 met de ondersteuning van versie 20.10. Veel organisaties werken daar nog mee, en zij moeten overstappen naar TimeXtender Classic of naar TimeXtender Data Integration (TDI). Welke route past, hangt vooral af van je huidige omgeving en van je plannen voor de komende jaren. TimeXtender
5 oktober 2026 FabCon Europe 2026: de Fabric-updates die er echt toe doen Copilot gaat nu rechtstreeks aan de slag met je semantic models. Dat klinkt mooi, maar het betekent ook dat elk rommelig model een veel groter publiek krijgt. Wij zetten de FabCon Europe 2026-aankondigingen op een rij die er in de praktijk toe doen: van governance en capacity overage tot nieuwe tools voor data engineers. Plus wat we je nu al zouden aanraden. AI Evenement Microsoft Fabric Power BI
1 september 2026 Qlik Answers-review: wat we leerden van tests in de praktijk We testten Qlik Answers op een echt verkoopmodel in productie om te zien hoe het omgaat met analytics in de praktijk. De resultaten waren veelbelovend, maar voor betrouwbare antwoorden moesten we zorgvuldig werken aan het logische model, mastermetingen, dimensies en de bedrijfscontext. AI Data-analyse Qlik Semantic Layer