dax: state the valid WEEKNUM codes and name the real pivot remedy (#2228)

This commit is contained in:
alosslessdev
2026-11-05 13:36:13 -05:00
parent a8b9913c31
commit 1198e1ddf9
2 changed files with 7 additions and 5 deletions
+6 -4
View File
@@ -327,10 +327,12 @@ pub static FUNCTIONS: &[FunctionSpec] = &[
&[overload(&[ParamKind::Date]), overload(&[ParamKind::Date, ParamKind::Number])],
ReturnType::Integer,
standard(false),
"WEEKNUM ( <Date> [, <ReturnType>] ) gives the week number within the year. ReturnType 1 \
(default) and 2-17 use system 1, where the week containing January 1 is week 1; \
ReturnType 21 uses ISO 8601 system 2, where the week containing the first Thursday is \
week 1. Text arguments are read with the same rules as DATEVALUE.",
"WEEKNUM ( <Date> [, <ReturnType>] ) gives the week number within the year. The documented \
codes are 1 (default), 2, 11-17 and 21: 1, 2 and 11-17 use system 1, where the week \
containing January 1 is week 1 (each code picks the first day of the week: 1 Sunday, 2 \
Monday, 11 Monday, 12 Tuesday, ... 17 Sunday), and 21 uses ISO 8601 system 2, where the \
week containing the first Thursday is week 1. Codes 3-10 are not valid. Text arguments \
are read with the same rules as DATEVALUE.",
&["WEEKNUM ( DATE ( 2024, 1, 15 ) )", "WEEKNUM ( Sales[Order Date], 21 )"],
),
spec(
+1 -1
View File
@@ -40,7 +40,7 @@ pub fn pivot_cross(model: &DataModel, measure: &str, row_fields: &[PivotField],
.and_then(|table| model.table_index(table));
let Some(table_index) = table_index else {
return Err(PivotError::Eval(EvalError::new(format!(
"measure `{measure}` has no home table; give the measure a home table or set `PivotTable::source_table`"
"measure `{measure}` has no home table; give the measure a home table, or set `PivotTable::source_table` and render through `PivotTable` instead of `pivot`/`pivot_cross`"
))));
};
let source = model.tables.get(table_index).ok_or_else(|| PivotError::Eval(EvalError::new("missing table")))?;