Multi mechanism
Sometimes you need to handle a list of elements, run computations on each element and aggregate the results either on input or output.
Inputs
In some cases, a Lansky needs to process a list of similar elements rather than a single set of values.
This is where the Multi mechanism comes in.
The Multi feature allows the engine to iterate over an array of data (for example, several vehicles, drivers, or insured persons) and inject each element into a dedicated Excel sheet to perform calculations such as totals or aggregations.
How it works
In the input sheet, the column A contains the data path, as usual — for example vehicles.
In another column (any column except B or C), you can reference a Multi sheet by writing:
multi:vehicle
When Lansky detects multi:xxxxx in a input sheet, it searches for a sheet named input_xxxxx.
Inside this input_xxxxx sheet, the data layout is horizontal instead of vertical:
- The first row defines the data keys (e.g.
catalog_price,option_price). - The following rows are automatically generated by Lansky, one per element in the input list.
Example
Suppose the input data is:
{
"vehicles": [
{ "catalog_price": 15000, "option_price": 5000 },
{ "catalog_price": 8000, "option_price": 500 }
]
}
The sheet input_vehicle_table will look like this once populated:
| catalog_price | option_price |
|---|---|
| 15000 | 5000 |
| 8000 | 500 |
Now, since all data is structured as rows, Excel formulas can easily aggregate values, such as:
=SUM(input_vehicle_table!A2:A30)
This will calculate the total catalog price across all vehicles.
The downside of this approach is that you must hardcode the number of rows when doing the sum. If you don't know the number of rows in advance, you can use the COUNTA function to count the number of rows.
Outputs
The output logic for Multi works very similarly to the input logic.
Inside the output sheet, if Lansky encounters an occurrence of multi:xxxx, it will look for a sheet named:
output_xxxx
Just like with input sheets, the first row defines the attributes (keys) that will appear in the output JSON.
Each subsequent row represents one object, where each cell value corresponds to the key defined in the first row.
For example, an output_vehicle sheet may look like this:
| total_price | discount | final_price |
|---|---|---|
| 20000 | 1000 | 19000 |
| 12000 | 0 | 12000 |
Lansky will convert this data into a JSON array of objects like:
[
{ "total_price": 20000, "discount": 1000, "final_price": 19000 },
{ "total_price": 12000, "discount": 0, "final_price": 12000 }
]
This means that for each row, Lansky builds a JSON object using the first row as property names and the corresponding cell values as data.
At the end of execution, the output will contain a complete array of objects under the matching key.
Example
In the previous example, with the input data:
{
"car": {
"catalog_price": 15000
}
}
The output will be:
{
"acceptation_rules": [
{
"rule": "max_catalog_price",
"accepted": true,
"message": "Catalog price accepted"
}
]
}
With the input data:
{
"car": {
"catalog_price": 35000
}
}
The output will be:
{
"acceptation_rules": [
{
"rule": "max_catalog_price",
"accepted": false,
"message": "Catalog price is above 25000, and is not accepted"
}
]
}
Skipping elements from the output
In some cases, you may want to exclude certain elements from the final output array — for instance, when a specific condition is not met or a rule fails.
To handle this, Lansky supports the special value __skip.
If an object in the output contains any attribute with the value __skip, that object will be automatically removed from the resulting JSON array.
This can be used to filter out rows directly from Excel without additional scripting logic.
Example
| rule | accepted | message | __skip |
|---|---|---|---|
| max_catalog_price | TRUE | "Catalog price accepted" | |
| min_catalog_price | FALSE | "Catalog price too low — not included" | __skip |
| electric_bonus | TRUE | "Electric vehicle bonus applied" |
Lansky will convert this data into:
[
{
"rule": "max_catalog_price",
"accepted": true,
"message": "Catalog price accepted"
},
{
"rule": "electric_bonus",
"accepted": true,
"message": "Electric vehicle bonus applied"
}
]
The row containing __skip will not appear in the output array.
This behavior is especially useful when your output needs to be conditionally filtered based on formula results — such as validation rules, eligibility checks, or optional features.
Because this mechanism is Excel-based, you can conditionally print "__skip" or not depending on a formula result.
That means your calculator can dynamically decide, using simple Excel logic, whether an item should appear in the output — adding a powerful layer of flexibility to the way Lansky handles data.
Custom columns
You are free to add as many columns as needed in a input_ or output_ sheet to perform intermediate calculations.
For instance:
| catalog_price | option_price | total_price |
|---|---|---|
| 15000 | 5000 | =SUM(A2+B2) |
| 8000 | 500 | =SUM(A3+B3) |
Here, column C (total_price) computes the sum of columns A and B for each row.
This makes it easy to apply additional formulas per row (e.g. discounts, taxes, ratios), and then compute a global total such as:
=SUM(input_vehicle_table!C2:C30)
This formula calculates the overall total price for all vehicles — combining both catalog and option prices.