Forum Discussion
Anonymous
8 years agoNot applicable
DAX for rolling average, formula error
I'm trying to calculate the average number of invoices vouchered or the past 5 days, however my DAX returns an error
"Calculation error in measure 'vouchered'[Measure]: a table of multiple values was supplied where a single value was expected."
This is my DAX:
Measure = CALCULATE(
AVERAGEX(vouchered, COUNT(vouchered[Invoice Number])),
FILTER(
vouchered,
DATESBETWEEN(
'vouchered'[Created Date].[Date],
DATEADD(LASTDATE(vouchered[Created Date]), -5, DAY),
DATEADD(LASTDATE(vouchered[Created Date]), 1, DAY)
)
)
)What's wrong with my code?
Sample data:
https://docs.google.com/spreadsheets/d/1rc2FTwyysZz8HseGIAf6UWK0uL_k9_l2L9QYgiDD0-I/edit?usp=sharing
3 Replies
- parry2kSuper User
DATEADD returns the table not column and that could be the reason.
- AnonymousNot applicable
I changed it, but I'm still getting an error. Here's my latest function:
Measure = CALCULATE( AVERAGEX(vouchered, COUNT(vouchered[Invoice Number])), FILTER( ALLEXCEPT(vouchered, vouchered[Created Date].[Date]), DATESBETWEEN( 'vouchered'[Created Date].[Date], LASTDATE(vouchered[Created Date].[Date])-5, LASTDATE(vouchered[Created Date].[Date]) ) ) )- AnonymousNot applicable
hey Anonymous
try using quick measures to get your past 5 days average.
kind regards;
HiltonM