Between · between
---
config:
flowchart:
useMaxWidth: false
---
flowchart TB
classDef ok fill:#d4edda,stroke:#28a745,color:#000
classDef partial fill:#fff3cd,stroke:#ffc107,color:#000
classDef refused fill:#d4edda,stroke:#28a745,stroke-width:3px,stroke-dasharray: 2 2,color:#000
classDef missing fill:#f8d7da,stroke:#dc3545,color:#000
classDef diverge fill:#cce5ff,stroke:#007bff,color:#000
classDef block fill:#2b3a4a,stroke:#2b3a4a,color:#fff,font-weight:bold
classDef ext fill:#fff,stroke:#666,color:#000,stroke-dasharray: 5 5
O["Between · between<br/>🟢4"]:::ok
subgraph G_ds["Dataset"]
direction LR
v_ds_sc_sc["between(DS, sc, sc)"]:::ok
end
subgraph G_comp["Component"]
direction LR
v_comp_sc_sc["between(comp, sc, sc)"]:::ok
v_comp_comp_comp["between(comp, comp, comp)"]:::ok
end
subgraph G_sc["Scalar"]
direction LR
v_sc_sc_sc["between(sc, sc, sc)"]:::ok
end
O --- G_ds
O --- G_comp
O --- G_sc
style G_ds fill:#f8f9fa,stroke:#495057,stroke-width:2px
style G_comp fill:#f8f9fa,stroke:#495057,stroke-width:2px,stroke-dasharray: 8 5
style G_sc fill:#f8f9fa,stroke:#495057,stroke-width:2px,stroke-dasharray: 2 3
click v_ds_sc_sc href "#form-ds-sc-sc"
click v_comp_sc_sc href "#form-comp-sc-sc"
click v_comp_comp_comp href "#form-comp-comp-comp"
click v_sc_sc_sc href "#form-sc-sc-sc"
Types
Takes any scalar · Gives boolean
Comes from: any operator that returns a value
Goes to · boolean — 27 operators in 8 blocks 🟢27
General purpose operators (1) 🟢1
Join operators (4) 🟢4
Boolean operators (4) 🟢4
Aggregate and Analytic operators (10) 🟢10
Data validation operators (1) 🟢1
Conditional operators (2) 🟢2
Clause operators (2) 🟢2
Definitions (VTL-DL) (3) 🟢3
Goes to · operators that take any scalar — 37 operators in 8 blocks 🟢37
General purpose operators (6) 🟢6
Comparison operators (10) 🟢10
Set operators (4) 🟢4
Aggregate and Analytic operators (7) 🟢7
Data validation operators (1) 🟢1
Conditional operators (1) 🟢1
Clause operators (7) 🟢7
Definitions (VTL-DL) (1) 🟢1
Forms
between(DS, sc, sc) 🟢 · any scalar → boolean
Manual example 1 🟢 pandas ✅ · DuckDB ✅
- Tests:
between(DS_1, 5, 10): every measure value ofDS_1against two scalar limits.- Manual:
Between, Example 1, output verbatim: “The operator returns true if op is greater than or equal to from and lower than or equal to to.”
- Expected:
bool_varis true for G (6) and false for R (-2).
DS_r:= between(DS_1, 5, 10);
| Id_1 | Id_2 | Id_3 | Id_4 | Me_1 |
|---|---|---|---|---|
| G | Total | Percentage | Total | 6 |
| R | Total | Percentage | Total | -2 |
| Id_1 | Id_2 | Id_3 | Id_4 | bool_var |
|---|---|---|---|---|
| G | Total | Percentage | Total | true |
| R | Total | Percentage | Total | false |
Files: script.vtl · input/DS_1.csv · input/DS_1.json · expected/DS_r.csv · expected/DS_r.json · example page ↗
between(comp, sc, sc) 🟢 · any scalar → boolean
Limits included and null operand 🟢 pandas ✅ · DuckDB ✅
- Tests:
between(Me_1, 5, 10)insidecalc: values on each limit, above the range, and null.- Manual:
Between: “The operator returns true if op is greater than or equal to from and lower than or equal to to. In other terms, it is a shortcut for the following:
op >= from and op <= to”. A null operand gives a null result: “Whenever a null value is involved in a comparison (>, <, >=, <=, in, not in, between) the result of the comparison is null” (User Manual).- Expected:
Me_2is a new boolean measure: true, true, false and null for ids 1 to 4: 5 and 10 are the limits themselves, so they are between 5 and 10; 11 is above; a null operand gives null;Me_1is kept.
DS_r := DS_1 [ calc Me_2 := between(Me_1, 5, 10) ];
| Id_1 | Me_1 |
|---|---|
| 1 | 5 |
| 2 | 10 |
| 3 | 11 |
| 4 |
| Id_1 | Me_1 | Me_2 |
|---|---|---|
| 1 | 5 | true |
| 2 | 10 | true |
| 3 | 11 | false |
| 4 |
Files: script.vtl · input/DS_1.csv · input/DS_1.json · expected/DS_r.csv · expected/DS_r.json · example page ↗
between(comp, comp, comp) 🟢 · any scalar → boolean
Component limits and null operand 🟢 pandas ✅ · DuckDB ✅
- Tests:
between(Me_1, Me_2, Me_3)insidecalc: the limits are components, so each data point has its own, and the operand is null in one.- Manual:
Between: “The operator returns true if op is greater than or equal to from and lower than or equal to to. In other terms, it is a shortcut for the following:
op >= from and op <= to”.fromandtomay be components: they are typedcomponent<scalar> | scalar.- Expected:
Me_4is a new boolean measure: true, true, false and null for ids 1 to 4: 5 and 10 are the limits of ids 1 and 2, so they count; 7 is below its limit 8;Me_1toMe_3are kept. A null operand makes both comparisons of the shortcut null, and so their conjunction: “Whenever a null value is involved in a comparison (>, <, >=, <=, in, not in, between) the result of the comparison is null” (User Manual).
DS_r := DS_1 [ calc Me_4 := between(Me_1, Me_2, Me_3) ];
| Id_1 | Me_1 | Me_2 | Me_3 |
|---|---|---|---|
| 1 | 5 | 5 | 10 |
| 2 | 10 | 1 | 10 |
| 3 | 7 | 8 | 9 |
| 4 | 1 | 2 |
| Id_1 | Me_1 | Me_2 | Me_3 | Me_4 |
|---|---|---|---|---|
| 1 | 5 | 5 | 10 | true |
| 2 | 10 | 1 | 10 | true |
| 3 | 7 | 8 | 9 | false |
| 4 | 1 | 2 |
Files: script.vtl · input/DS_1.csv · input/DS_1.json · expected/DS_r.csv · expected/DS_r.json · example page ↗
between(sc, sc, sc) 🟢 · any scalar → boolean
Upper limit included 🟢 pandas ✅ · DuckDB ✅
- Tests:
between(SC_1, SC_2, SC_3)withSC_1= 10,SC_2= 5 andSC_3= 10: an operand equal to the upper limit.- Manual:
Between: “The operator returns true if op is greater than or equal to from and lower than or equal to to. In other terms, it is a shortcut for the following:
op >= from and op <= to”.- Expected:
SC_r = true, a Boolean: 10 >= 5 and 10 <= 10; it would be false if the limit were excluded.
SC_r := between(SC_1, SC_2, SC_3);
| SC_1 | SC_2 | SC_3 |
|---|---|---|
| 10 | 5 | 10 |
Name |
Type |
Value |
|---|---|---|
|
Boolean |
|
Files: script.vtl · input/scalars.csv · input/scalars.json · expected/scalars.json · example page ↗