Hi team,
I am trying to replicate a Tableau FIXED LOD calculation in QuickSight.
Tableau (working):
SUM({
FIXED DATEPART(‘month’,[Sales Period]),
(IF [Sales Period] <= [DateLimit]
THEN DATENAME(‘weekday’,[Sales Period])
END)
: COUNTD(DATETRUNC(‘week’,[Sales Period]))
})
(DateLimit is a Date parameter with default value 2020-09-01 and Sales Period is direct date field)
QuickSight attempt:
distinctCountOver(
truncDate(‘WK’,{Sales Period}),
[
extract(‘MM’,{Sales Period}),
ifelse({Sales Period}<=${DateLimit},
formatDate({Sales Period},‘EEEE’),
NULL)
],
PRE_AGG
)
This throws:
”Please correct the distinctCountOver to use PRE_AGG or PRE_FILTER levels and partiton only by column references.”
So I created calculated fields:
weekstart = truncDate(‘WK’,{Sales Period})
month = extract(‘MM’,{Sales Period})
weekday = ifelse({Sales Period}<=${DateLimit},
formatDate({Sales Period},‘EEEE’),
NULL)
Then used:
distinctCountOver(weekstart, [month, weekday], PRE_AGG)
Now the field validates, but when added to a Pivot Table visual it throws:
DISTINCTCOUNTOVER_INVALID_ARGUMENT
How can I correctly implement this Tableau FIXED logic (Month + Weekday → COUNTD Week) in QuickSight without this error?
(Note : the quicksight calculation works when partitioning only by month.
But when I add weekday to the partition, the Pivot visual throws DISTINCTCOUNTOVER_INVALID_ARGUMENT.)