Period indicator · period_indicator
---
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["Period indicator · period_indicator<br/>🟢4"]:::ok
subgraph G_ds["Dataset"]
direction LR
v_ds["period_indicator(DS)"]:::ok
end
subgraph G_comp["Component"]
direction LR
v_comp["filter period_indicator(comp)"]:::ok
v_in_filter_no_operand["filter period_indicator()"]:::ok
end
subgraph G_sc["Scalar"]
direction LR
v_sc["period_indicator(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 href "#form-ds"
click v_comp href "#form-comp"
click v_sc href "#form-sc"
click v_in_filter_no_operand href "#form-in-filter-no-operand"
Types
Takes time_period · Gives duration
Comes from · time_period — 6 operators in 2 blocks 🟢6
General purpose operators (1) 🟢1
Comes from · operators that return any type (their input's) — 37 operators in 9 blocks 🟢37
General purpose operators (6) 🟢6
Join operators (4) 🟢4
Time operators (1) 🟢1
Set operators (4) 🟢4
Hierarchical aggregation (1) 🟢1
Aggregate and Analytic operators (8) 🟢8
Data validation operators (1) 🟢1
Conditional operators (3) 🟢3
Goes to · duration — 6 operators in 3 blocks 🟢6
General purpose operators (1) 🟢1
Time operators (4) 🟢4
Definitions (VTL-DL) (1) 🟢1
Goes to · operators that take any scalar — 49 operators in 9 blocks 🟢49
General purpose operators (6) 🟢6
Join operators (4) 🟢4
Comparison operators (11) 🟢11
Set operators (4) 🟢4
Aggregate and Analytic operators (10) 🟢10
Data validation operators (1) 🟢1
Conditional operators (3) 🟢3
Clause operators (9) 🟢9
Definitions (VTL-DL) (1) 🟢1
Forms
period_indicator(DS) 🟢 · time_period → duration
Manual example 1 🟢 pandas ✅ · DuckDB ✅
- Tests:
period_indicator(DS_1): the period indicator of the time_period identifierId_3of each data point, in the one measureduration_var.- Manual:
Period indicator, Example 1, output verbatim: “The operator returns a Data Set with the same Identifiers of op and one Measure of type duration named duration_var.”
- Expected:
Afor the year2010andQfor2013Q1, which the manual’s output writes2013-Q1, the same period;Me_1is dropped.
DS_r := period_indicator ( DS_1 );
| Id_1 | Id_2 | Id_3 | Me_1 |
|---|---|---|---|
| A | 1 | 2010 | 10 |
| A | 1 | 2013Q1 | 50 |
| Id_1 | Id_2 | Id_3 | duration_var |
|---|---|---|---|
| A | 1 | 2010 | A |
| A | 1 | 2013-Q1 | Q |
Files: script.vtl · input/DS_1.csv · input/DS_1.json · expected/DS_r.csv · expected/DS_r.json · example page ↗
filter period_indicator(comp) 🟢 · time_period → duration
Manual example 2 🟢 pandas ✅ · DuckDB ✅
- Tests:
period_indicator(Id_3)insidefilter, compared withcast("A", duration): the annual data points are kept.- Manual:
Period indicator, Example 2, output verbatim: “The period indicator is the part of the time_period value which denotes the duration of the time period (e.g. day, week, month…).”
- Expected:
2010has the indicatorAand2013Q1hasQ, so the data point of2010is kept, with all its components.
DS_r := DS_1 [ filter period_indicator ( Id_3 ) = cast("A", duration) ];
| Id_1 | Id_2 | Id_3 | Me_1 |
|---|---|---|---|
| A | 1 | 2010 | 10 |
| A | 1 | 2013Q1 | 50 |
| Id_1 | Id_2 | Id_3 | Me_1 |
|---|---|---|---|
| A | 1 | 2010 | 10 |
Files: script.vtl · input/DS_1.csv · input/DS_1.json · expected/DS_r.csv · expected/DS_r.json · example page ↗
filter period_indicator() 🟢 · time_period → duration
Keeps the quarterly data point 🟢 pandas ✅ · DuckDB ✅
- Tests:
period_indicator()with its operand left out, insidefilter, compared withcast("Q", duration)as in Manual example 2; the one time_period identifier,Id_2, has the indicatorsA(2010),Q(2010Q1) andM(2010M01).- Manual:
Period indicator: “if used in a clause the operand op can be omitted”, and then “the Data Set to which the clause is applied has exactly one Identifier of type time_period”, from whose value the operator “extracts the period indicator”.
- Expected:
The one data point whose indicator is
Q:A,2010Q1, 20.
DS_r := DS_1[filter period_indicator() = cast("Q", duration)];
| Id_1 | Id_2 | Me_1 |
|---|---|---|
| A | 2010 | 10 |
| A | 2010Q1 | 20 |
| B | 2010M01 | 30 |
| Id_1 | Id_2 | Me_1 |
|---|---|---|
| A | 2010Q1 | 20 |
Files: script.vtl · input/DS_1.csv · input/DS_1.json · expected/DS_r.csv · expected/DS_r.json · example page ↗
period_indicator(sc) 🟢 · time_period → duration
Quarterly period 🟢 pandas ✅ · DuckDB ✅
- Tests:
period_indicator(SC_1)on a scalar time_period,SC_1= 2010Q1, an input scalar, as VTL has no time_period literal.- Manual:
Period indicator: “period_indicator returns the period indicator of a time_period value. The period indicator is the part of the time_period value which denotes the duration of the time period (e.g. day, week, month…).”
- Expected:
DS_r = Q, a Duration: the manual’s default conversion from string to time_period (Type conversion) reads2010Q1as the first quarter of 2010.
DS_r := period_indicator(SC_1);
| SC_1 |
|---|
| 2010Q1 |
Name |
Type |
Value |
|---|---|---|
|
Duration |
|
Files: script.vtl · input/scalars.csv · input/scalars.json · expected/scalars.json · example page ↗