Minimum value · min
---
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["Minimum value · min<br/>🟢8"]:::ok
subgraph G_ds["Dataset"]
direction LR
v_ds_no_group["min(DS)"]:::ok
v_ds_group_by["min(DS group by Id)"]:::ok
v_ds_group_except["min(DS group except Id)"]:::ok
v_ds_group_all["min(DS group all time_agg(#quot;A#quot;))"]:::ok
v_ds_having["min(DS group by Id having cond)"]:::ok
v_analytic_ds["min(DS over (partition by Id))"]:::ok
end
subgraph G_comp["Component"]
direction LR
v_comp_in_aggr["DS#91;aggr Me #58;#61; min(Me) group by Id#93;"]:::ok
v_analytic_comp["DS#91;calc Me #58;#61; min(Me over (partition by Id))#93;"]:::ok
end
subgraph G_use["Used with"]
direction LR
used__clause__aggr["aggr ↗<br/><small>used in</small>"]:::ext
used__clause__calc["calc ↗<br/><small>used in over()</small>"]:::ext
end
O --- G_ds
O --- G_comp
O -.- G_use
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_use fill:#ffffff,stroke:#868e96,stroke-width:1px,stroke-dasharray: 1 4
click v_ds_no_group href "#form-ds-no-group"
click v_ds_group_by href "#form-ds-group-by"
click v_ds_group_except href "#form-ds-group-except"
click v_ds_group_all href "#form-ds-group-all"
click v_ds_having href "#form-ds-having"
click v_comp_in_aggr href "#form-comp-in-aggr"
click v_analytic_ds href "#form-analytic-ds"
click v_analytic_comp href "#form-analytic-comp"
click used__clause__aggr href "../clause/aggr.html" "Aggregation · aggr"
click used__clause__calc href "../clause/calc.html" "Calculation of a Component · calc"
Types
Takes boolean, any scalar · Gives any type
Comes from: any operator that returns a value
Goes to: whatever takes its input's type
Forms
min(DS) 🟢 · any scalar → any type
Single group no identifiers 🟢 pandas ✅ · DuckDB ✅
- Tests:
minwith no grouping clause, over the shared input with two Number measures and no null.- Manual:
Aggregate invocation: “If the grouping clause is omitted, then all the input Data Points are aggregated in a single group and the clause returns a Data Set that contains a single Data Point and has no Identifiers.”
- Expected:
one data point with no identifiers:
Me_1= 1 andMe_2= 0.5, the smallest values.
DS_r := min ( DS_1 );
| Id_1 | Id_2 | Me_1 | Me_2 |
|---|---|---|---|
| A | 2020Q1 | 3 | 1.500000 |
| A | 2020Q2 | 1 | 3.500000 |
| A | 2021Q1 | 5 | 2.500000 |
| A | 2021Q2 | 1 | 0.500000 |
| B | 2020Q1 | 4 | 6.500000 |
| B | 2020Q2 | 8 | 4.500000 |
| Me_1 | Me_2 |
|---|---|
| 1 | 0.500000 |
Files: script.vtl · input/DS_1.csv · input/DS_1.json · expected/DS_r.csv · expected/DS_r.json · example page ↗
min(DS group by Id) 🟢 · any scalar → any type
Manual example 1 🟢 pandas ✅ · DuckDB ✅
- Tests:
minat data set level grouped byId_1, over one Integer measure.- Manual:
Minimun value, Example 1, output verbatim: “The operator returns the minimum value of the input values.”
- Expected:
3 for 2011, the smallest of 3, 5 and 7, and 2 for 2012, of 2 and 4;
Me_1stays Integer.
DS_r := min ( DS_1 group by Id_1 );
| Id_1 | Id_2 | Id_3 | Me_1 |
|---|---|---|---|
| 2011 | A | XX | 3 |
| 2011 | A | YY | 5 |
| 2011 | B | YY | 7 |
| 2012 | A | XX | 2 |
| 2012 | B | YY | 4 |
| Id_1 | Me_1 |
|---|---|
| 2011 | 3 |
| 2012 | 2 |
Files: script.vtl · input/DS_1.csv · input/DS_1.json · expected/DS_r.csv · expected/DS_r.json · example page ↗
String measure 🟢 pandas ✅ · DuckDB ✅
- Tests:
minover a String measure, grouped byId_1.- Manual:
Minimun value: “For other comparable scalar types (for example time, string, boolean), the result has the same type as the operand”.
- Expected:
the smallest Strings,
appleforAanddateforB; inAit is neither the first nor the last value in the order ofId_2. Strings compare character by character (the Greater than page gives false for"hello" > "hi"), and these words start with different letters: apple < fig < kiwi < pear and date < plum.
DS_r := min ( DS_1 group by Id_1 );
| Id_1 | Id_2 | Me_1 |
|---|---|---|
| A | 2020Q1 | kiwi |
| A | 2020Q2 | apple |
| A | 2021Q1 | pear |
| A | 2021Q2 | fig |
| B | 2020Q1 | plum |
| B | 2020Q2 | date |
| Id_1 | Me_1 |
|---|---|
| A | apple |
| B | date |
Files: script.vtl · input/DS_1.csv · input/DS_1.json · expected/DS_r.csv · expected/DS_r.json · example page ↗
min(DS group except Id) 🟢 · any scalar → any type
Drops the listed identifier 🟢 pandas ✅ · DuckDB ✅
- Tests:
minwithgroup except Id_2: the data points are grouped byId_1, the identifier that it does not name.- Manual:
Aggregate invocation: “group except: the Data Points are grouped by the values of the Identifiers not specified as groupingId. The Identifiers specified as groupingId are dropped in the result.”
- Expected:
Id_1and the two measures, withoutId_2: 1 and 0.5 forA, 4 and 4.5 forB, the smallest values.
DS_r := min ( DS_1 group except Id_2 );
| Id_1 | Id_2 | Me_1 | Me_2 |
|---|---|---|---|
| A | 2020Q1 | 3 | 1.500000 |
| A | 2020Q2 | 1 | 3.500000 |
| A | 2021Q1 | 5 | 2.500000 |
| A | 2021Q2 | 1 | 0.500000 |
| B | 2020Q1 | 4 | 6.500000 |
| B | 2020Q2 | 8 | 4.500000 |
| Id_1 | Me_1 | Me_2 |
|---|---|---|
| A | 1 | 0.500000 |
| B | 4 | 4.500000 |
Files: script.vtl · input/DS_1.csv · input/DS_1.json · expected/DS_r.csv · expected/DS_r.json · example page ↗
min(DS group all time_agg("A")) 🟢 · any scalar → any type
Quarters to years 🟢 pandas ✅ · DuckDB ✅
- Tests:
minwith the deprecatedgroup all time_agg ( "A" ), which turns each quarter ofId_2into its year, written2020or2021.- Manual:
Aggregate invocation: “group all: converts the values of an Identifier Component using conversionExpr and keeps all the resulting Identifiers”; Time aggregation: “On time_period type, the operator maps the input value into the comprising larger time period specified by the periodIndTo parameter”.
- Expected:
Id_1, the year and the two measures: 1 and 1.5 forA, 2020, 1 and 0.5 forA, 2021and 4 and 4.5 forB, 2020.
DS_r := min ( DS_1 group all time_agg ( "A" ) );
| Id_1 | Id_2 | Me_1 | Me_2 |
|---|---|---|---|
| A | 2020Q1 | 3 | 1.500000 |
| A | 2020Q2 | 1 | 3.500000 |
| A | 2021Q1 | 5 | 2.500000 |
| A | 2021Q2 | 1 | 0.500000 |
| B | 2020Q1 | 4 | 6.500000 |
| B | 2020Q2 | 8 | 4.500000 |
| Id_1 | Id_2 | Me_1 | Me_2 |
|---|---|---|---|
| A | 2020 | 1 | 1.500000 |
| A | 2021 | 1 | 0.500000 |
| B | 2020 | 4 | 4.500000 |
Files: script.vtl · input/DS_1.csv · input/DS_1.json · expected/DS_r.csv · expected/DS_r.json · example page ↗
min(DS group by Id having cond) 🟢 · any scalar, boolean → any type
Two measures 🟢 pandas ✅ · DuckDB ✅
- Tests:
minwithhaving, over the two measures of the shared input.- Manual:
Aggregate invocation: the havingCondition “must invoke aggregate operators”, and “only groups for which havingCondition evaluates to true appear in the result”. The condition aggregates
Me_1only, where the manual and the reading of #1119 agree.- Expected:
min ( Me_1 ) < 2is 1 forAand 4 forB, so onlyAis kept, with 1 and 0.5.
DS_r := min ( DS_1 group by Id_1 having min ( Me_1 ) < 2 );
| Id_1 | Id_2 | Me_1 | Me_2 |
|---|---|---|---|
| A | 2020Q1 | 3 | 1.500000 |
| A | 2020Q2 | 1 | 3.500000 |
| A | 2021Q1 | 5 | 2.500000 |
| A | 2021Q2 | 1 | 0.500000 |
| B | 2020Q1 | 4 | 6.500000 |
| B | 2020Q2 | 8 | 4.500000 |
| Id_1 | Me_1 | Me_2 |
|---|---|---|
| A | 1 | 0.500000 |
Files: script.vtl · input/DS_1.csv · input/DS_1.json · expected/DS_r.csv · expected/DS_r.json · example page ↗
One measure 🟢 pandas ✅ · DuckDB ✅
- Tests:
minwith thehavingof Two measures, on a single-measure operand: the shared input withoutMe_2.- Manual:
Aggregate invocation: “only groups for which havingCondition evaluates to true appear in the result”; the page does not restrict
havingto single-measure operands.- Expected:
min ( Me_1 ) < 2holds forAonly, which is kept withMe_1= 1.
DS_r := min ( DS_1 group by Id_1 having min ( Me_1 ) < 2 );
| Id_1 | Id_2 | Me_1 |
|---|---|---|
| A | 2020Q1 | 3 |
| A | 2020Q2 | 1 |
| A | 2021Q1 | 5 |
| A | 2021Q2 | 1 |
| B | 2020Q1 | 4 |
| B | 2020Q2 | 8 |
| Id_1 | Me_1 |
|---|---|
| A | 1 |
Files: script.vtl · input/DS_1.csv · input/DS_1.json · expected/DS_r.csv · expected/DS_r.json · example page ↗
min(DS over (partition by Id)) 🟢 · any scalar → any type
Whole partition without order 🟢 pandas ✅ · DuckDB ✅
- Tests:
minas an analytic function at data set level, partitioned byId_1, with no order and no window clause.- Manual:
Analytic invocation: “If windowClause is not specified, then the set of Data Points which contribute to the analytic operation is the whole partition which the current Data Point belongs to”. With no order clause, the two defaults that the page gives for an omitted window agree.
- Expected:
every data point gets the values of its partition: 1 and 0.5 in
A, 4 and 4.5 inB.
DS_r := min ( DS_1 over ( partition by Id_1 ) );
| Id_1 | Id_2 | Me_1 | Me_2 |
|---|---|---|---|
| A | 2020Q1 | 3 | 1.500000 |
| A | 2020Q2 | 1 | 3.500000 |
| A | 2021Q1 | 5 | 2.500000 |
| A | 2021Q2 | 1 | 0.500000 |
| B | 2020Q1 | 4 | 6.500000 |
| B | 2020Q2 | 8 | 4.500000 |
| Id_1 | Id_2 | Me_1 | Me_2 |
|---|---|---|---|
| A | 2020Q1 | 1 | 0.500000 |
| A | 2020Q2 | 1 | 0.500000 |
| A | 2021Q1 | 1 | 0.500000 |
| A | 2021Q2 | 1 | 0.500000 |
| B | 2020Q1 | 4 | 4.500000 |
| B | 2020Q2 | 4 | 4.500000 |
Files: script.vtl · input/DS_1.csv · input/DS_1.json · expected/DS_r.csv · expected/DS_r.json · example page ↗
DS[aggr Me := min(Me) group by Id] 🟢 · any scalar → any type
Keeps only calculated measure 🟢 pandas ✅ · DuckDB ✅
- Tests:
minat component level inaggr, grouped byId_1.- Manual:
Aggregate invocation: “For the invocation at Component level, the resulting Data Set has the Measures explicitly calculated (all the other Measures are dropped because no aggregation behaviour is specified for them).”
- Expected:
Id_1andMe_3only: 1 forAand 4 forB, the smallest values.
DS_r := DS_1 [ aggr Me_3 := min ( Me_1 ) group by Id_1 ];
| Id_1 | Id_2 | Me_1 | Me_2 |
|---|---|---|---|
| A | 2020Q1 | 3 | 1.500000 |
| A | 2020Q2 | 1 | 3.500000 |
| A | 2021Q1 | 5 | 2.500000 |
| A | 2021Q2 | 1 | 0.500000 |
| B | 2020Q1 | 4 | 6.500000 |
| B | 2020Q2 | 8 | 4.500000 |
| Id_1 | Me_3 |
|---|---|
| A | 1 |
| B | 4 |
Files: script.vtl · input/DS_1.csv · input/DS_1.json · expected/DS_r.csv · expected/DS_r.json · example page ↗
DS[calc Me := min(Me over (partition by Id))] 🟢 · any scalar → any type
Whole partition without order 🟢 pandas ✅ · DuckDB ✅
- Tests:
minas an analytic function incalc, partitioned byId_1, with no order and no window clause.- Manual:
Analytic invocation: “the resulting Data Set retains all the original components of the input Data Set plus the components explicitly calculated by it”; with no order and no window clause, the window is the whole partition.
- Expected:
the input, plus
Me_3= 1 on the data points ofAand 4 on those ofB.
DS_r := DS_1 [ calc Me_3 := min ( Me_1 over ( partition by Id_1 ) ) ];
| Id_1 | Id_2 | Me_1 | Me_2 |
|---|---|---|---|
| A | 2020Q1 | 3 | 1.500000 |
| A | 2020Q2 | 1 | 3.500000 |
| A | 2021Q1 | 5 | 2.500000 |
| A | 2021Q2 | 1 | 0.500000 |
| B | 2020Q1 | 4 | 6.500000 |
| B | 2020Q2 | 8 | 4.500000 |
| Id_1 | Id_2 | Me_1 | Me_2 | Me_3 |
|---|---|---|---|---|
| A | 2020Q1 | 3 | 1.500000 | 1 |
| A | 2020Q2 | 1 | 3.500000 | 1 |
| A | 2021Q1 | 5 | 2.500000 | 1 |
| A | 2021Q2 | 1 | 0.500000 | 1 |
| B | 2020Q1 | 4 | 6.500000 | 4 |
| B | 2020Q2 | 8 | 4.500000 | 4 |
Files: script.vtl · input/DS_1.csv · input/DS_1.json · expected/DS_r.csv · expected/DS_r.json · example page ↗