ValQ - Plan
FormulaProductChangelogStart Trial
  • Introduction to ValQ
    • Get ValQ
    • The ValQ Workflow
  • Model
    • Get Data
    • Create Model
      • Dynamic Model
      • Custom Model
      • Import a Model
    • Model Editor
      • Node Operations
      • Editor Features
    • Node Settings
    • Templates
      • Apply Template
      • Manage Template Nodes
      • Import Template
      • Export Template
    • Formula Functions
      • Logical Functions
        • IF
        • SWITCH
        • AND
        • OR
        • NOT
        • XOR
        • IFNAN
      • Math Functions
        • SUM
        • SUBTRACT
        • PRODUCT
        • DIVISION
        • AVERAGE
        • AVERAGEEXZERO
        • AVERAGEEXNEG
        • AVERAGEEXZERONEG
        • COUNT
        • ABS
        • MIN
        • MAX
        • POWER
        • SQRT
        • EXP
        • LOG
        • ROUND
        • FLOOR
        • CEILING
      • Finance Functions
        • IRR
        • NPV
        • PMT
        • IPMT
        • FV
        • PV
        • CUMIPMT
        • CUMPRINC
        • RATE
      • Range Functions
        • RANGE
        • LastNPeriods
        • Get
        • ForEach
        • findByTitle
        • GETCURRENTRANGE
        • GETROWVALUE
        • THIS_SOURCE_KEY
        • PERIOD_LOOKUP
        • PRIOR_SERIES_PERIOD_LOOKUP
      • Static Identifiers
        • THIS/ME
        • CURRENT_SERIES*
        • CURRENT_SERIES_ID*
        • CURRENT_PERIOD_INDEX
        • CURRENT_NODE_VALUES
        • DS.SERIES
      • Node Properties
        • Node Properties Explanation
    • Global Settings
  • Plan
    • Create New Plan
    • Time Series Forecasting
    • Allocation Features
      • Goal Seek
      • Distribute
      • Copy to Periods
    • Driver Based Planning
      • Enabling Driver Based Plan
      • Configuring Driver Inputs
      • Bulk Configuration of Drivers
    • Plan Interface
  • Simulate
    • Create a Scenario
    • Perform Simulations
    • Manage Scenarios
    • Simulation Interface
    • Add Notes
    • Compare Scenarios
    • Scenario Analysis by Node
    • Create Initiatives in a Scenario
      • Steps to create initiatives
    • Create your Presentation
    • Understanding the Node Components
  • Report
    • Variance Analysis Report
  • ValQ Premium FAQs
  • Glossary
  • Resources
  • Release Notes
Powered by GitBook
On this page
  • Syntax
  • Arguments
  • Example
  • Explanation
  1. Model
  2. Formula Functions
  3. Range Functions

ForEach

When we have multiple nodes and want to execute the same operation for each of the node, we will use the ForEach function. It is not applicable for performing operation to a single node.

Syntax

ForEach (Array,Iterator)

Arguments

Arguments
Datatype
Description

Array

Node Name

The node for which the iterator statement is executed for all the periods.

Iterator

This, Children, Parent

The operation that is to be executed.

Example

Consider the below scenario where we have Revenue and cost items for different regions. Our objective is to calculate the total costs incurred for marketing.

Year
2020

US Marketing (FOREACH)

14000

New York (Sum children)

2510

Men (Subtract Children)

1000

Revenue (Sum Children)

4500

Sales

4000

Receivables

500

Costs (Sum Children)

3500

Marketing

3000

Salary

500

Women (Subtract Children)

1510

Revenue (Sum Children)

5510

Sales

5000

Receivables

510

Costs (Sum Children)

4000

Marketing

2000

Salary

2000

LA (Sum children)

-4120

Men (Subtract Children)

-1200

Revenue (Sum Children)

4000

Sales

3500

Receivables

500

Costs (Sum Children)

5200

Marketing

4000

Salary

1200

Women (Subtract Children)

-2920

Revenue (Sum Children)

4080

Sales

3540

Receivables

540

Costs (Sum Children)

7000

Marketing

5000

Salary

2000

To achieve this, the following formula should be written in the [US Marketing] node,

SUM(FOREACH(THIS.CHILDREN,FOREACH(THIS.CHILDREN.THIS,THIS.CHILDREN.GET(2).CHILDREN.GET(1))))

Explanation

(FOREACH (THIS.CHILDREN,

As we are entering the formula in the parent node of both regions - New York and LA , THIS.CHILDREN will refer to each of the children of [US Marketing] node which is [New York] and [LA]

FOREACH (THIS.CHILDREN.

This will refer to each of the child nodes of [New York] and [LA] which are [Men] and [Women]

THIS,

This refers to that same node so it will be [Men] and [Women]

THIS.CHILDREN.GET(2).

This will consider the second child [Costs] of the Men and Women nodes as we have mentioned Get(2)

CHILDREN.GET(1) )))

This will get the value of the first child of [Costs] that is [Marketing]. Sum of these [Marketing]nodes are returned which is 14000.

PreviousGetNextfindByTitle

Last updated 1 year ago