### ValQ GET Function Example Source: https://docs.valq.com/model/formula-functions/range-functions/get Demonstrates how to use the GET function in ValQ to retrieve a specific period's value from a node. This function is typically used within a ValQ formula to reference historical data. ```ValQ [Discount (2024)] = [Discount (2023)].Get(12) ``` -------------------------------- ### AND Function Example in Valq Source: https://docs.valq.com/model/formula-functions/logical-functions/and This example demonstrates how to use the AND function in Valq to conditionally set a price based on the number of licenses and usage duration. It highlights the use of AND within an IF statement for complex logic. ```Valq IF(AND([No of Licenses]>500, [Duration]<24), 20, 25) ``` -------------------------------- ### ValQ NOT Function Syntax and Example Source: https://docs.valq.com/model/formula-functions/logical-functions/not Demonstrates the syntax of the NOT function in ValQ and provides a practical example of its usage within an IF statement to calculate sales bonus eligibility. The example shows how NOT negates a condition, affecting the outcome of the IF statement. ```ValQ Formula IF(NOT([Total Sales]>[Sales Goal]),0,[Bonus %]*[Total Sales]) ``` -------------------------------- ### POWER Function Syntax and Example - ValQ Source: https://docs.valq.com/model/formula-functions/math-functions/power Demonstrates the syntax and usage of the POWER function in ValQ for calculating compound interest. The function takes a base value and an exponent, returning the result of the exponentiation. This example shows how to use node references within the POWER function for financial calculations. ```ValQ [Principal](POWER(1+[Rate]/[Monthly Compound], [Time]*[Monthly Compound])) ``` -------------------------------- ### Get Last N Simulated Series Periods (ValQ) Source: https://docs.valq.com/model/formula-functions/node-properties/node-properties-explanation The [NODE].act.LastNPeriods(n) function retrieves a selected range of values from the Simulated Series. It must be used in conjunction with aggregate functions like SUM, PRODUCT, or SUBTRACT. For example, SUM([Sales].act.LastNPeriods(2)) calculates the sum of the simulated values for the preceding two periods. ```ValQ SUM([Sales].act.LastNPeriods(2)) ``` -------------------------------- ### OR Function Syntax and Example Source: https://docs.valq.com/model/formula-functions/logical-functions/or Demonstrates the syntax and usage of the OR function within a conditional IF statement. It evaluates if 'Sales Quantity' is greater than 50 or 'Customer Ranking' is equal to 1, determining the price accordingly. This example highlights how the OR function simplifies complex conditional logic. ```Valq Formula IF(OR([Sales Quantity]>50, [Customer Ranking]==1),20,25) ``` -------------------------------- ### Get Range of Values (ValQ) Source: https://docs.valq.com/model/formula-functions/node-properties/node-properties-explanation Retrieves values for a specified range of periods within a node, defined by start and end indices. The number of periods returned corresponds to the difference between the end and start indices plus one. The display is typically set to 'Sim. months'. ```ValQ SUM([Sales].RANGE(9,12)) ``` -------------------------------- ### Get Range of Comparison Series Data (Valq) Source: https://docs.valq.com/model/formula-functions/node-properties/node-properties-explanation The `[NODE].tgt.RANGE(start_index, end_index)` function retrieves a specified range of values from the Comparison Series (target) of a node. This function is useful for analyzing target performance over specific periods. An example is `SUM([Sales].tgt.RANGE(9,12))`, which sums comparison sales from September to December. ```Valq SUM([Sales].tgt.RANGE(9,12)) ``` -------------------------------- ### Get Specific Period Value of Comparison Series (Valq) Source: https://docs.valq.com/model/formula-functions/node-properties/node-properties-explanation The `[NODE].tgt.GET(period_index)` function retrieves the value of the Comparison Series (target) for a given period index. This enables focused analysis of target performance at a specific point in time. For example, `[Sales].tgt.GET(6)` returns the comparison value for June. ```Valq [Sales].tgt.GET(6) ``` -------------------------------- ### CUMPRINC Function Example Calculation Source: https://docs.valq.com/model/formula-functions/finance-functions/cumprinc Demonstrates how to use the CUMPRINC function to calculate cumulative principal payments for a loan. This example uses specific values for rate, Nper, PV, start_period, end_period, and Type. ```Spreadsheet Formula CUMPRINC(10%/12, [Nper], [Loan Amount], 1, [End Period], 1) ``` -------------------------------- ### Valq GETROWVALUE Function Usage Example Source: https://docs.valq.com/model/formula-functions/range-functions/getrowvalue This example demonstrates how to use the GETROWVALUE function in Valq to allocate a specific year's sales value from a parent node to all periods of a child node. It requires the source key of the parent and uses the GET method to retrieve the value. ```Valq Formula DS._Sum_of_2020.GETROWVALUE(THIS.PARENT.SOURCE_KEY).GET(CPI) ``` -------------------------------- ### Period-Specific Unit Sales Calculation using SWITCH Source: https://docs.valq.com/model/formula-functions/logical-functions/switch This example demonstrates calculating unit sales for different periods using the SWITCH function. It incorporates growth rates, unit prices, unit costs, fixed costs, and target operating income to determine the unit sales for each period. The formula leverages THIS, PERIOD_LOOKUP, and other node references for complex calculations. ```ValQ Formula SWITCH(CPI,1,100,2,THIS.PERIOD_LOOKUP(3,100)[Growth%],3,THIS.PERIOD_LOOKUP(2,100)[Growth%],4,THIS.PERIOD_LOOKUP(1,100)*[Growth%],5,([Fixed cost]+[Target Operating income])/([Unit price]-[Unit cost])) ``` -------------------------------- ### Selecting Data Ranges by Index in ValQ Source: https://docs.valq.com/model/formula-functions/node-properties Demonstrates how to select a range of data points from a node or its series using start and end indices. This allows for focused data extraction. ```ValQ Script NODE.Range(start_index, end_index) NODE.act.Range(start_index, end_index) NODE.base.Range(start_index, end_index) NODE.tgt.Range(start_index, end_index) ``` -------------------------------- ### Conditional Discount Rate using SWITCH Source: https://docs.valq.com/model/formula-functions/logical-functions/switch This example shows how to set a conditional discount rate based on the current period index. It uses the SWITCH function to assign a 15% discount rate for specific months (Jan, Aug, Nov, Dec) and a default 20% for all other months. This is useful for applying different rates based on temporal conditions. ```ValQ Formula SWITCH(CURRENT_PERIOD_INDEX,1,0.15,8,0.15,11,0.15,12,0.15,0.20) ``` -------------------------------- ### MAX Function Syntax and Usage Source: https://docs.valq.com/model/formula-functions/math-functions/max Demonstrates the syntax of the MAX function, which takes one or more numerical values or node references as arguments and returns the largest among them. The example shows how to use .ALL_PERIODS to consider all time periods for a node. ```ValQ Formula MAX([Demand].ALL_PERIODS) ``` -------------------------------- ### Get Specific Period Value of Baseline Series (Valq) Source: https://docs.valq.com/model/formula-functions/node-properties/node-properties-explanation The `[NODE].base.GET(period_index)` function returns the value of the Baseline Series for a specified period index. This function is useful for isolating and examining baseline data points. An example is `[Sales].base.GET(6)`, which retrieves the baseline value for June. ```Valq [Sales].base.GET(6) ``` -------------------------------- ### Get Last N Comparison Series Periods (ValQ) Source: https://docs.valq.com/model/formula-functions/node-properties/node-properties-explanation The [NODE].tgt.LastNPeriods(n) function retrieves a selected range of values from the Comparison Series. This function is designed to be used with other aggregate functions like SUM, PRODUCT, and SUBTRACT. An example is SUM([Sales].tgt.LastNPeriods(2)), which returns the sum of the comparison values for the previous two periods. ```ValQ SUM([Sales].tgt.LastNPeriods(2)) ``` -------------------------------- ### Get Baseline Values for All Periods (ValQ) Source: https://docs.valq.com/model/formula-functions/node-properties/node-properties-explanation Retrieves baseline values for all periods of a specified node. This function is typically used in conjunction with other ValQ functions like SUM or GET(CPI). It requires a node with defined period values. ```ValQ [Cost of Sales].ALL_PERIODS.GET(CPI) ``` -------------------------------- ### Get Simulated Values for All Periods (ValQ) Source: https://docs.valq.com/model/formula-functions/node-properties/node-properties-explanation Retrieves simulated values for all periods of a specified node's simulated series. This function is used with other ValQ functions like SUM or GET(CPI). It accesses the 'act' (actual/simulated) series. ```ValQ [Sales].act.ALL_PERIODS.GET(CPI) ``` -------------------------------- ### Get Specific Period Value (Valq) Source: https://docs.valq.com/model/formula-functions/node-properties/node-properties-explanation The `[NODE].GET(period_index)` function returns the value of a node for a specific period, identified by its index. This is a fundamental function for accessing individual data points within a series. For example, `[Sales].GET(6)` retrieves the value for the 6th period (June). ```Valq [Sales].GET(6) ``` -------------------------------- ### Get Last N Periods for Aggregation (Valq) Source: https://docs.valq.com/model/formula-functions/node-properties/node-properties-explanation The `[NODE].LastNPeriods(n)` function returns the values for the last 'n' periods of a node's series. This function is designed to be used in conjunction with other aggregate functions like SUM, PRODUCT, or SUBTRACT to perform calculations on recent data. For example, `SUM([Sales].LastNPeriods(2))` calculates the sum of the last two periods. ```Valq SUM([Sales].LastNPeriods(2)) ``` -------------------------------- ### Get Simulated Periods for Baseline Series (ValQ) Source: https://docs.valq.com/model/formula-functions/node-properties/node-properties-explanation Retrieves simulated period values for a baseline series. Similar to the comparison series function, this is often used with aggregation functions. It also considers the active simulation period. ```ValQ [Sales].base.SIM_PERIODS.GET(CPI) ``` -------------------------------- ### ValQ RANGE Function Usage Source: https://docs.valq.com/model/formula-functions/range-functions/range Demonstrates how to use the RANGE function to calculate the sum of interest payments for a specific period (April to June). The function takes start and end indices as arguments and returns the values within that range. This example assumes a node named 'Interest payments' with monthly data. ```ValQ Formula SUM([Interest payments].Range(4,6)) ``` -------------------------------- ### Get Simulated Values for Simulated Periods (ValQ) Source: https://docs.valq.com/model/formula-functions/node-properties/node-properties-explanation Retrieves simulated values for the active simulation periods of a specified node. This function is used with other ValQ functions like SUM or GET(CPI). The active simulation period is defined within the ValQ model. ```ValQ [Cost of Sales].SIM_PERIODS.GET(CPI) ``` -------------------------------- ### Retrieving Specific Period Values in ValQ Source: https://docs.valq.com/model/formula-functions/node-properties Explains how to get the value for a specific period by providing its index. This is useful for accessing individual data points. ```ValQ Script NODE.Get(period_index) NODE.act.Get(period_index) NODE.base.Get(period_index) NODE.tgt.Get(period_index) ``` -------------------------------- ### CURRENT_SERIES Function Syntax and Example Source: https://docs.valq.com/model/formula-functions/static-identifiers/current_series Demonstrates the syntax for the CURRENT_SERIES function, which assigns values conditionally based on a series argument. It takes a series name, followed by a conditional check ('==') and two values. The first value is assigned if the series matches, and the second value is assigned otherwise. This function is currently under development. ```Valq CURRENT_SERIES == 'series'? value1:value2 ``` ```Valq CURRENT_SERIES == 'base'? 100:85 ``` -------------------------------- ### Get Range of Simulated Series Data (Valq) Source: https://docs.valq.com/model/formula-functions/node-properties/node-properties-explanation The `[NODE].act.RANGE(start_index, end_index)` function retrieves a specified range of values from the Simulated Series of a node. It's often used with aggregation functions like SUM to calculate totals over a period. For example, `SUM([Sales].act.RANGE(9,12))` sums simulated sales from September to December. ```Valq SUM([Sales].act.RANGE(9,12)) ``` -------------------------------- ### Get Last N Baseline Series Periods (ValQ) Source: https://docs.valq.com/model/formula-functions/node-properties/node-properties-explanation The [NODE].base.LastNPeriods(n) function retrieves a selected range of values from the Baseline Series. It requires integration with aggregate functions such as SUM, PRODUCT, or SUBTRACT. For instance, SUM([Sales].base.LastNPeriods(2)) computes the sum of the baseline values for the last two periods. ```ValQ SUM([Sales].base.LastNPeriods(2)) ``` -------------------------------- ### Get Simulated Periods for Comparison Series (ValQ) Source: https://docs.valq.com/model/formula-functions/node-properties/node-properties-explanation Retrieves simulated period values for a comparison series. This function is typically used in conjunction with other aggregation functions like SUM or GET(CPI). It operates on the active simulation period defined within the model. ```ValQ [Sales].tgt.SIM_PERIODS.GET(CPI) ``` -------------------------------- ### Retrieving Node Series Values in ValQ Source: https://docs.valq.com/model/formula-functions/node-properties Explains how to get the values for the simulated ('act'), target ('tgt'), and baseline ('base') series of a node. These represent different data streams associated with a node. ```ValQ Script NODE.act NODE.tgt NODE.base ``` -------------------------------- ### Get Selected Simulation Period Aggregated Value (ValQ) Source: https://docs.valq.com/model/formula-functions/node-properties/node-properties-explanation Returns the aggregated value specifically for the selected simulation period. This is useful for analyzing data within a defined subset of time, such as specific months chosen in a simulation tab. ```ValQ [Sales].SEL ``` -------------------------------- ### Get Simulated Period Values for Simulated Series (ValQ) Source: https://docs.valq.com/model/formula-functions/node-properties/node-properties-explanation Retrieves simulated period values specifically from the simulated series of a node. This function is used with other ValQ functions like SUM or GET(CPI). It focuses on the intersection of simulated periods and the simulated series. ```ValQ [Sales].act.SIM_PERIODS.GET(CPI) ``` -------------------------------- ### PERIOD_LOOKUP Function Usage in Valq Source: https://docs.valq.com/model/formula-functions/range-functions/period_lookup Demonstrates how to use the PERIOD_LOOKUP function within Valq to calculate sequential values. It requires a node reference before the function call and takes an offset and an initial value as arguments. The offset determines the number of periods to look back or forward, and the initial value sets the starting point. ```Valq [Closing Balance].PERIOD_LOOKUP(-1,30000000) ``` ```Valq THIS.PERIOD_LOOKUP(-1,400)*(1+[Growth rate (Years 2-5)]) ``` -------------------------------- ### Get Comparison Series Values for All Periods (ValQ) Source: https://docs.valq.com/model/formula-functions/node-properties/node-properties-explanation Retrieves values for all periods of a specified node's comparison series. This function is used with other ValQ functions like SUM or GET(CPI). It accesses the 'tgt' (target/comparison) series. ```ValQ [Sales].tgt.ALL_PERIODS.GET(CPI) ``` -------------------------------- ### Getting the Last N Periods of Data in ValQ Source: https://docs.valq.com/model/formula-functions/node-properties Shows how to retrieve the data for the last 'n' periods from a node or its series. This is a common operation for analyzing recent trends. ```ValQ Script NODE.LastNPeriods(n) NODE.act.LastNPeriods(n) NODE.base.LastNPeriods(n) NODE.tgt.LastNPeriods(n) ``` -------------------------------- ### Calculate Cumulative Interest Payments using CUMIPMT Source: https://docs.valq.com/model/formula-functions/finance-functions/cumipmt This formula calculates the cumulative interest paid for a loan between a start and end period. It requires the interest rate per period, total number of periods, present value of the loan, the start and end periods for the calculation, and the payment type (0 for end of period, non-zero for start of period). ```valq CUMIPMT([Rate]/12, [Number of Years]*12, [Loan Amount], 1, [End Period], 1) ``` -------------------------------- ### Get Period Till Date Aggregated Value (ValQ) Source: https://docs.valq.com/model/formula-functions/node-properties/node-properties-explanation Calculates and returns the aggregated value from the beginning of the period up to the current date or selected simulation months. If 'Full Year' is selected, it displays the full year's value instead of PTD. ```ValQ [Sales].PTD ``` -------------------------------- ### Get Range of Baseline Series Data (Valq) Source: https://docs.valq.com/model/formula-functions/node-properties/node-properties-explanation The `[NODE].base.RANGE(start_index, end_index)` function retrieves a specified range of values from the Baseline Series of a node. Similar to the simulated series, it can be used with aggregation functions. For instance, `SUM([Sales].base.RANGE(9,12))` calculates the sum of baseline sales from September to December. ```Valq SUM([Sales].base.RANGE(9,12)) ``` -------------------------------- ### SIM_PERIODS (Comparison Series) Source: https://docs.valq.com/model/formula-functions/node-properties/node-properties-explanation Retrieves simulated period values for the comparison series. This function is typically used in conjunction with other aggregation functions like SUM or GET. ```APIDOC ## GET [NODE].tgt.SIM_PERIODS ### Description Returns simulated period values of the comparison series. This function can only be used along with other functions like SUM, GET(CPI). The periods in a model are defined from Jan to Dec and the active simulation period is from Jun to Dec. ### Method GET ### Endpoint `[NODE].tgt.SIM_PERIODS` ### Parameters #### Query Parameters - **function** (string) - Required - The function to apply, e.g., `GET(CPI)`. ### Request Example ``` GET /websites/valq?node=[Sales].tgt.SIM_PERIODS&function=GET(CPI) ``` ### Response #### Success Response (200) - **values** (array) - An array of simulated period values. #### Response Example ```json { "values": [ 100, 110, 120, 130, 140, 150 ] } ``` ``` -------------------------------- ### Get Specific Period Value of Simulated Series (Valq) Source: https://docs.valq.com/model/formula-functions/node-properties/node-properties-explanation The `[NODE].act.GET(period_index)` function retrieves the value of the Simulated Series for a specific period index. This allows for targeted analysis of simulated data points. For instance, `[Sales].act.GET(6)` returns the simulated value for June. ```Valq [Sales].act.GET(6) ``` -------------------------------- ### PRIOR_SERIES_PERIOD_LOOKUP Function Usage Source: https://docs.valq.com/model/formula-functions/range-functions/prior_series_period_lookup This snippet demonstrates how to use the PRIOR_SERIES_PERIOD_LOOKUP function in a formula. It shows how to reference a node's closing balance and use PRIOR_SERIES_PERIOD_LOOKUP to fetch a prior period's value, which is then used in conjunction with PERIOD_LOOKUP. The initial value parameter is crucial for establishing the starting point of the calculation. ```Formula [Closing Cash Balance].PERIOD_LOOKUP(-1, [Closing Cash Balance].PRIOR_SERIES_PERIOD_LOOKUP(1,12,183439)) ``` -------------------------------- ### Get Total Aggregated Value (ValQ) Source: https://docs.valq.com/model/formula-functions/node-properties/node-properties-explanation Returns the aggregated value of a node across all defined periods. This function provides a single consolidated value for the entire dataset represented by the node. ```ValQ [Sales].TOTAL ``` -------------------------------- ### Calculate Average Excluding Zeros and Negatives using AVERAGEEXZERONEG Source: https://docs.valq.com/model/formula-functions/math-functions/averageexzeroneg This snippet demonstrates how to use the AVERAGEEXZERONEG function to calculate the average of sales data from different regions (East, South, Central, West). It excludes regions with zero or negative profit, as indicated by the example scenario. The function takes node references as arguments. ```ValQ Formula AVERAGEEXZERONEG([East],[South],[Central],[West]) ``` -------------------------------- ### Calculate Loan Payments using PMT Function Source: https://docs.valq.com/model/formula-functions/finance-functions/pmt This snippet demonstrates how to use the PMT function to calculate monthly loan payments. It requires the interest rate per period, the total number of periods, the loan amount (present value), an optional future value (defaulting to zero), and a type indicating payment timing (0 for end of period, non-zero for start). ```Generic PMT( Rate, Nper, PV, FV?, Type? ) ``` ```Generic PMT( 0.83%, [Number of periods], [Loan Amount], 0, 1 ) ``` -------------------------------- ### Calculate Future Value with FV Function Source: https://docs.valq.com/model/formula-functions/finance-functions/fv This snippet demonstrates how to use the FV function to calculate the future value of an investment. It requires the interest rate per period, the total number of periods, and the periodic payment amount. Optional arguments include the present value and the type of payment (start or end of period). ```Formula FV([Interest Rate],[Number of Periods],[Payment],0,0) ``` -------------------------------- ### MIN Function Syntax and Usage Source: https://docs.valq.com/model/formula-functions/math-functions/min Demonstrates the syntax of the MIN function and how to use it to find the minimum demand across all periods for a given node. The function takes node references or numbers as arguments. ```ValQ Formula MIN([Demand].ALL_PERIODS) ``` -------------------------------- ### ValQ FOREACH Loop and Object Referencing Source: https://docs.valq.com/model/formula-functions/range-functions/foreach Demonstrates the use of the FOREACH loop in ValQ to iterate through child nodes and access specific data points using THIS and CHILDREN.GET. This is useful for complex data aggregation and calculations within the ValQ modeling environment. ```ValQ Formula FOREACH (THIS.CHILDREN, FOREACH (THIS.CHILDREN. THIS, THIS.CHILDREN.GET(2). CHILDREN.GET(1) ) ) ``` -------------------------------- ### Accessing All and Simulation Periods in ValQ Source: https://docs.valq.com/model/formula-functions/node-properties Shows how to retrieve all available period values or specifically the simulation period values for a node or its series. This is crucial for time-series analysis. ```ValQ Script NODE.ALL_PERIODS NODE.SIM_PERIODS NODE.act.ALL_PERIODS NODE.tgt.ALL_PERIODS NODE.base.ALL_PERIODS NODE.act.SIM_PERIODS NODE.tgt.SIM_PERIODS NODE.base.SIM_PERIODS ``` -------------------------------- ### Accessing Node Parent and Children in ValQ Source: https://docs.valq.com/model/formula-functions/node-properties Demonstrates how to access the parent node and its visible or hidden children. These properties are fundamental for navigating the node hierarchy. ```ValQ Script NODE.PARENT NODE.CHILDREN NODE.VISIBLE_CHILDREN NODE.HIDDEN_CHILDREN ``` -------------------------------- ### Implement Month-on-Month Growth using CURRENT_NODE_VALUES Source: https://docs.valq.com/model/formula-functions/static-identifiers/current_node_values This formula demonstrates how to set an initial value for the first period and then calculate subsequent period values based on a percentage growth from the previous period using CURRENT_NODE_VALUES and CURRENT_PERIOD_INDEX. ```ValQ Formula IF(CURRENT_PERIOD_INDEX==1,1000,CURRENT_NODE_VALUES.GET(CURRENT_PERIOD_INDEX-1)*1.1) ``` -------------------------------- ### ValQ SUM Function Usage Source: https://docs.valq.com/model/formula-functions/math-functions/sum Demonstrates how to use the SUM function in ValQ to calculate total sales across different regions. The function takes node references as arguments to sum their values. ```ValQ Formula SUM([East], [South], [Central], [West]) ``` -------------------------------- ### Accessing Aggregated Node Values in ValQ Source: https://docs.valq.com/model/formula-functions/node-properties Demonstrates how to retrieve aggregated values for a node, including the total across all periods ('TOTAL'), period-to-date ('PTD'), and simulation periods ('SEL'). ```ValQ Script NODE.TOTAL NODE.PTD NODE.SEL ``` -------------------------------- ### RANGE Aggregation Source: https://docs.valq.com/model/formula-functions/node-properties/node-properties-explanation Retrieves selected range values of the node based on start and end indices. ```APIDOC ## GET [NODE].RANGE(START_INDEX,END_INDEX) ### Description Returns selected range values of the node. The value display should be selected as Sim.months and the number of periods should be selected in Sim periods. If we keep it as Jan to Apr it will give us 4 month's value. If we keep it as Jan to May it will give us 5 month's value. ### Method GET ### Endpoint `[NODE].RANGE(START_INDEX,END_INDEX)` ### Parameters #### Path Parameters - **START_INDEX** (integer) - Required - The starting index of the range (inclusive). - **END_INDEX** (integer) - Required - The ending index of the range (inclusive). ### Request Example ``` GET /websites/valq?node=[Sales].RANGE(9,12) ``` ### Response #### Success Response (200) - **values** (array) - An array of values within the specified range. #### Response Example ```json { "values": [ 90, 100, 110, 120 ] } ``` ``` -------------------------------- ### Calculate Logarithm using LOG Function Source: https://docs.valq.com/model/formula-functions/math-functions/log This snippet demonstrates how to use the LOG function to calculate the logarithm of a value to a specified base. The function accepts a value and a base as arguments, which can be numerical literals or references to nodes containing these values. The output is the computed logarithm. ```Valq LOG([value], [base]) ``` -------------------------------- ### Retrieving Node Title in ValQ Source: https://docs.valq.com/model/formula-functions/node-properties Explains how to access the title property of a node. This provides a human-readable name for the node. ```ValQ Script NODE.TITLE ``` -------------------------------- ### Finance Functions API Source: https://docs.valq.com/model/formula-functions/finance-functions This section details the available finance functions and their usage. ```APIDOC ## Finance Functions API ### Description This API provides access to various financial calculation functions. ### Endpoints #### IRR ##### Description Returns the internal rate of return for a series of cash flows. Node references are also accepted as arguments. ##### Method GET (or POST, depending on implementation) ##### Endpoint `/websites/valq/finance-functions/irr` ##### Parameters ###### Query Parameters - **Values** (array of numbers) - Required - The series of cash flows. - **Guess** (number) - Optional - Your guess for the IRR. ###### Request Example ```json { "values": [100, -20, -30, 50], "guess": 0.1 } ``` ###### Response ####### Success Response (200) - **result** (number) - The internal rate of return. ####### Response Example ```json { "result": 0.15 } ``` #### NPV ##### Description Returns the net present value of an investment based on a discount rate and a series of future payments (negative values) and income (positive values). ##### Method GET (or POST, depending on implementation) ##### Endpoint `/websites/valq/finance-functions/npv` ##### Parameters ###### Query Parameters - **Rate** (number) - Required - The discount rate per period. - **value1** (number) - Required - The first future payment or income. - **valueN** (number) - Optional - Additional future payments or incomes. ###### Request Example ```json { "rate": 0.05, "values": [100, -20, -30, 50] } ``` ###### Response ####### Success Response (200) - **result** (number) - The net present value. ####### Response Example ```json { "result": 75.34 } ``` #### PMT ##### Description Calculates the payment for a loan based on constant payments and a constant interest rate. ##### Method GET (or POST, depending on implementation) ##### Endpoint `/websites/valq/finance-functions/pmt` ##### Parameters ###### Query Parameters - **Rate** (number) - Required - The interest rate per period. - **Nper** (number) - Required - The total number of payments for the loan. - **PV** (number) - Required - The present value, or the total amount that a series of future payments is worth now. - **FV** (number) - Optional - The future value, or a cash balance you want to attain after the last payment is made. Defaults to 0. - **Type** (number) - Optional - The number 0 or 1 and indicates when payments are due. Defaults to 0. ###### Request Example ```json { "rate": 0.05, "nper": 10, "pv": 10000 } ``` ###### Response ####### Success Response (200) - **result** (number) - The payment for the loan. ####### Response Example ```json { "result": -1321.51 } ``` #### IPMT ##### Description Returns the interest payment for a given period for an investment, based on periodic, constant payments and a constant interest rate. ##### Method GET (or POST, depending on implementation) ##### Endpoint `/websites/valq/finance-functions/ipmt` ##### Parameters ###### Query Parameters - **Rate** (number) - Required - The interest rate per period. - **Per** (number) - Required - The period for which you want to find the interest and must be in the same units as nper. - **Nper** (number) - Required - The total number of payments for the loan. - **PV** (number) - Required - The present value, or the total amount that a series of future payments is worth now. - **FV** (number) - Optional - The future value, or a cash balance you want to attain after the last payment is made. Defaults to 0. - **Type** (number) - Optional - The number 0 or 1 and indicates when payments are due. Defaults to 0. ###### Request Example ```json { "rate": 0.05, "per": 3, "nper": 10, "pv": 10000 } ``` ###### Response ####### Success Response (200) - **result** (number) - The interest payment for the specified period. ####### Response Example ```json { "result": -456.23 } ``` #### FV ##### Description Returns the future value of an investment based on periodic, constant payments and a constant interest rate. ##### Method GET (or POST, depending on implementation) ##### Endpoint `/websites/valq/finance-functions/fv` ##### Parameters ###### Query Parameters - **Rate** (number) - Required - The interest rate per period. - **Nper** (number) - Required - The total number of payment periods. - **Pmt** (number) - Optional - The payment made each period. Defaults to 0. - **PV** (number) - Required - The present value, or the lump-sum amount that a series of future payments is worth right now. - **Type** (number) - Optional - The number 0 or 1 and indicates when payments are due. Defaults to 0. ###### Request Example ```json { "rate": 0.05, "nper": 10, "pv": 10000 } ``` ###### Response ####### Success Response (200) - **result** (number) - The future value of the investment. ####### Response Example ```json { "result": 16288.95 } ``` #### PV ##### Description Returns the present value of an investment. ##### Method GET (or POST, depending on implementation) ##### Endpoint `/websites/valq/finance-functions/pv` ##### Parameters ###### Query Parameters - **Rate** (number) - Required - The interest rate per period. - **Nper** (number) - Required - The total number of payment periods for the investment. - **Pmt** (number) - Optional - The payment made each period. Defaults to 0. - **FV** (number) - Required - The future value, or a cash balance you want to attain after the last payment is made. - **Type** (number) - Optional - The number 0 or 1 and indicates when payments are due. Defaults to 0. ###### Request Example ```json { "rate": 0.05, "nper": 10, "fv": 10000 } ``` ###### Response ####### Success Response (200) - **result** (number) - The present value of the investment. ####### Response Example ```json { "result": -6139.13 } ``` #### CUMIPMT ##### Description Returns the cumulative interest paid between two periods. ##### Method GET (or POST, depending on implementation) ##### Endpoint `/websites/valq/finance-functions/cumipmt` ##### Parameters ###### Query Parameters - **Rate** (number) - Required - The interest rate per period. - **Nper** (number) - Required - The total number of payment periods. - **PV** (number) - Required - The present value. - **start_period** (number) - Required - The first period in the calculation. - **end_period** (number) - Required - The last period in the calculation. - **Type** (number) - Required - Indicates when payments are due (0 or 1). ###### Request Example ```json { "rate": 0.05, "nper": 10, "pv": 10000, "start_period": 1, "end_period": 5, "type": 0 } ``` ###### Response ####### Success Response (200) - **result** (number) - The cumulative interest paid. ####### Response Example ```json { "result": -2277.05 } ``` #### CUMPRINC ##### Description Returns the cumulative principal paid on a loan between two periods. ##### Method GET (or POST, depending on implementation) ##### Endpoint `/websites/valq/finance-functions/cumprinc` ##### Parameters ###### Query Parameters - **Rate** (number) - Required - The interest rate per period. - **Nper** (number) - Required - The total number of payment periods. - **PV** (number) - Required - The present value. - **start_period** (number) - Required - The first period in the calculation. - **end_period** (number) - Required - The last period in the calculation. - **Type** (number) - Required - Indicates when payments are due (0 or 1). ###### Request Example ```json { "rate": 0.05, "nper": 10, "pv": 10000, "start_period": 1, "end_period": 5, "type": 0 } ``` ###### Response ####### Success Response (200) - **result** (number) - The cumulative principal paid. ####### Response Example ```json { "result": -3859.47 } ``` #### RATE ##### Description Returns the interest rate per period of a loan or an investment. ##### Method GET (or POST, depending on implementation) ##### Endpoint `/websites/valq/finance-functions/rate` ##### Parameters ###### Query Parameters - **Nper** (number) - Required - The total number of periods for the loan or investment. - **PMT** (number) - Required - The payment made each period. - **PV** (number) - Optional - The present value. Defaults to 0. - **FV** (number) - Optional - The future value. Defaults to 0. - **Type** (number) - Optional - Indicates when payments are due (0 or 1). Defaults to 0. - **Guess** (number) - Optional - Your guess for the interest rate. Defaults to 0.1. ###### Request Example ```json { "nper": 10, "pmt": -100, "pv": 1000 } ``` ###### Response ####### Success Response (200) - **result** (number) - The interest rate per period. ####### Response Example ```json { "result": 0.025 } ``` ``` -------------------------------- ### Conditional Value Assignment with CURRENT_SERIES_ID Source: https://docs.valq.com/model/formula-functions/static-identifiers/current_series_id This snippet demonstrates the syntax and usage of the CURRENT_SERIES_ID function for conditional value assignment. It checks if the current series matches a specified label ('Forecast' in the example) and assigns '100' if it matches, otherwise assigns '85'. This is useful for setting different values based on the context of a series. ```Valq Formula CURRENT_SERIES_ID == 'Forecast'? 100:85 ``` -------------------------------- ### Math Functions API Source: https://docs.valq.com/model/formula-functions/math-functions This section details the various mathematical functions supported, including arithmetic operations, statistical calculations, and number transformations. ```APIDOC ## Math Functions API ### Description This API provides access to a comprehensive set of mathematical functions for performing calculations within the ValQ platform. These functions can operate on numbers or node references. ### Functions #### SUM * **Description**: Adds all the numbers in the arguments. * **Syntax**: `SUM(value1, ...valueN?)` * **Returns**: `number` #### SUBTRACT * **Description**: Subtracts all the values in the arguments. * **Syntax**: `SUBTRACT(value1, ...valueN?)` * **Returns**: `number` #### PRODUCT * **Description**: Multiplies all the values in the arguments. * **Syntax**: `PRODUCT(value1, ...valueN?)` * **Returns**: `number` #### DIVISION * **Description**: Divides all the values in the arguments. * **Syntax**: `DIVISION(value1, ...valueN?)` * **Returns**: `number` #### AVERAGE * **Description**: Returns the average (arithmetic mean) of its arguments. * **Syntax**: `AVERAGE(value1, ...valueN?)` * **Returns**: `number` #### AVERAGEEXZERO * **Description**: Returns the average (arithmetic mean) of its arguments excluding zeros. * **Syntax**: `AVERAGEEXZERO(value1, ...valueN?)` * **Returns**: `number` #### AVERAGEEXNEG * **Description**: Returns the average (arithmetic mean) of its arguments excluding negatives. * **Syntax**: `AVERAGEEXNEG(value1, ...valueN?)` * **Returns**: `number` #### AVERAGEEXZERONEG * **Description**: Returns the average (arithmetic mean) of its arguments excluding zeros and negatives. * **Syntax**: `AVERAGEEXZERONEG(value1, ...valueN?)` * **Returns**: `number` #### COUNT * **Description**: Counts the number of items in a range. * **Syntax**: `COUNT(value1, ...valueN?)` * **Returns**: `number` #### ABS * **Description**: Returns the absolute value of a number. * **Syntax**: `ABS(value)` * **Returns**: `number` #### MIN * **Description**: Returns the smallest number in a set of values. * **Syntax**: `MIN(value1, ...valueN?)` * **Returns**: `number` #### MAX * **Description**: Returns the largest number in a set of values. * **Syntax**: `MAX(value1, ...valueN?)` * **Returns**: `number` #### POWER * **Description**: Returns the result of a number raised to a power. * **Syntax**: `POW(value, power)` * **Returns**: `number` #### SQRT * **Description**: Returns the square root of a number. * **Syntax**: `SQRT(value)` * **Returns**: `number` #### EXP * **Description**: Returns e raised to the power of a given number. * **Syntax**: `EXP(value)` * **Returns**: `number` #### LOG * **Description**: Returns the logarithm of a number to the specified base. * **Syntax**: `LOG(value, base)` * **Returns**: `number` #### ROUND * **Description**: Returns the rounded value of the specified node or number. * **Syntax**: `ROUND(value)` * **Returns**: `number` #### FLOOR * **Description**: Returns the rounded down value of the specified node or number. * **Syntax**: `FLOOR(value)` * **Returns**: `number` #### CEILING * **Description**: Returns the rounded up value of the specified node or number. * **Syntax**: `CEIL(value)` * **Returns**: `number` ``` -------------------------------- ### ValQ Formula for Calculating Total Marketing Costs Source: https://docs.valq.com/model/formula-functions/range-functions/foreach This formula is designed to be implemented in a ValQ node to calculate the total marketing costs. It utilizes FOREACH and SUM functions to iterate through child nodes and aggregate specific values. The formula assumes a hierarchical data structure where marketing costs are nested within cost items. ```ValQ Formula SUM(FOREACH(THIS.CHILDREN, FOREACH(THIS.CHILDREN.THIS, THIS.CHILDREN.GET(2).CHILDREN.GET(1)))) ``` -------------------------------- ### Calculate Loan Interest Payment with IPMT Source: https://docs.valq.com/model/formula-functions/finance-functions/ipmt This snippet demonstrates how to use the IPMT function to calculate the interest paid on a loan for a specific period. It requires the interest rate per period, the period number, the total number of periods, the present value (loan amount), and optionally the future value and payment type. The example assumes monthly payments at the beginning of the period. ```Valq IPMT([Rate]/12, [Period], [Number of periods], [Loan Amount], 0, 1) ``` -------------------------------- ### SIM_PERIODS (Baseline Series) Source: https://docs.valq.com/model/formula-functions/node-properties/node-properties-explanation Retrieves simulated period values for the baseline series. Similar to the comparison series function, it's often used with aggregation functions. ```APIDOC ## GET [NODE].base.SIM_PERIODS ### Description Returns simulated period values of the baseline series. This function can only be used along with other functions like SUM, GET(CPI). The periods in a model are defined from Jan to Dec and the active simulation period is from Jun to Dec. ### Method GET ### Endpoint `[NODE].base.SIM_PERIODS` ### Parameters #### Query Parameters - **function** (string) - Required - The function to apply, e.g., `GET(CPI)`. ### Request Example ``` GET /websites/valq?node=[Sales].base.SIM_PERIODS&function=GET(CPI) ``` ### Response #### Success Response (200) - **values** (array) - An array of simulated period values. #### Response Example ```json { "values": [ 90, 95, 100, 105, 110, 115 ] } ``` ``` -------------------------------- ### XOR Function Usage in Formula Source: https://docs.valq.com/model/formula-functions/logical-functions/xor This snippet demonstrates how to use the XOR function within a formula to conditionally set a value. It takes multiple logical tests as arguments and returns a specific value based on whether exactly one of the conditions is true. The formula uses an IF statement to apply the XOR logic. ```formula IF(XOR([Sales Quantity]>50, [Customer Ranking]==1), 20, 25) ``` -------------------------------- ### Range Functions API Source: https://docs.valq.com/model/formula-functions/range-functions This section details the various range functions available in the API, allowing for data retrieval and manipulation based on periods and indices. ```APIDOC ## Range Functions API Documentation This document outlines the various functions available for working with ranges and periods within the API. ### Range #### Description Returns the values between the specified start and end periods. #### Method N/A (This is a function, not an HTTP endpoint) #### Endpoint N/A #### Parameters * **start_index** (number) - Required - The starting period index. * **end_index** (number) - Required - The ending period index. ### LastNPeriods #### Description Returns the values of the last 'n' periods. #### Method N/A (This is a function, not an HTTP endpoint) #### Endpoint N/A #### Parameters * **n** (number) - Required - The number of periods to retrieve from the end. ### Get #### Description Returns the values of the specified period index. #### Method N/A (This is a function, not an HTTP endpoint) #### Endpoint N/A #### Parameters * **period_index** (number) - Required - The index of the period to retrieve. ### ForEach #### Description Applies the same operation for multiple nodes. #### Method N/A (This is a function, not an HTTP endpoint) #### Endpoint N/A #### Parameters * **Array** (Array) - Required - The array of nodes to iterate over. * **Iterator** (Function) - Required - The function to apply to each node. ### findByTitle #### Description Tagging/Grouping function. Returns the value of the nodes which has the specified title. #### Method N/A (This is a function, not an HTTP endpoint) #### Endpoint N/A #### Parameters * **searchString** (string) - Required - The title to search for. ### GETCURRENTRANGE #### Description Returns the current range values based on the period selection. #### Method N/A (This is a function, not an HTTP endpoint) #### Endpoint N/A #### Parameters * **DS.(SERIES)** (Object) - Required - The data series object. ### GETROWVALUE #### Description Returns the value of the source key row. #### Method N/A (This is a function, not an HTTP endpoint) #### Endpoint N/A #### Parameters * **DS.(SERIES)** (Object) - Required - The data series object. * **sourceKey** (string) - Required - The key of the row to retrieve. ### THIS_SOURCE_KEY #### Description Returns the value of the mentioned source key. #### Method N/A (This is a function, not an HTTP endpoint) #### Endpoint N/A #### Parameters * **DS.(SERIES)** (Object) - Required - The data series object. ### PRIOR_SERIES_PERIOD_LOOKUP #### Description Returns the specified period's value. #### Method N/A (This is a function, not an HTTP endpoint) #### Endpoint N/A #### Parameters * **seriesOffset** (number) - Required - The offset of the series. * **periodIndex** (number) - Required - The index of the period. * **initialValue** (any) - Optional - The initial value. ### PERIOD_LOOKUP #### Description Returns the specified series's value. #### Method N/A (This is a function, not an HTTP endpoint) #### Endpoint N/A #### Parameters * **offset** (number) - Required - The offset of the series. * **initialValue** (any) - Optional - The initial value. ``` -------------------------------- ### Calculate Present Value using PV Function Source: https://docs.valq.com/model/formula-functions/finance-functions/pv This snippet demonstrates how to use the PV function to calculate the present value of an investment. It requires the interest rate per period, the total number of periods, and the payment made each period. The future value and payment type are optional arguments. ```ValQ Formula PV([Interest Rate], [Number of Periods], [Payments Made], 0, 0) ``` -------------------------------- ### SWITCH Function - Multi-Condition Evaluation Source: https://docs.valq.com/model/formula-functions/logical-functions The SWITCH function compares an expression against a list of values and returns a corresponding result for the first match. An optional default value can be provided if no match is found. ```ValQ Formula SWITCH(expression, value1, result1, value2, result2, ..., value_n, result_n, default?) ``` -------------------------------- ### AND Function - All Conditions True Source: https://docs.valq.com/model/formula-functions/logical-functions The AND function checks if all provided logical arguments are TRUE. It returns TRUE only if every argument evaluates to TRUE, otherwise it returns FALSE. ```ValQ Formula AND(logical_test1, ..., logical_test2?) ``` -------------------------------- ### Calculate Average Sales using AVERAGE Function Source: https://docs.valq.com/model/formula-functions/math-functions/average This snippet demonstrates how to use the AVERAGE function to calculate the average sales across different regions. It takes node references for regional sales as input and outputs the calculated average. ```ValQ Formula AVERAGE([East],[South],[Central],[West]) ``` -------------------------------- ### Calculate Square Root using SQRT Function Source: https://docs.valq.com/model/formula-functions/math-functions/sqrt This snippet demonstrates how to use the SQRT function to calculate the square root of values from a node. It assumes a node named '[Number]' contains the values for which the square root is to be calculated. The result is displayed in a 'Square root' node. ```ValQ Formula SQRT([Number]) ```