Forum Discussion
jcastr02
Post Prodigy
1 year agoAverage on or after a specific date
I have a file with store closing dates and daily sales.... I'd like to be able to see the average of the Daily Sales column only for data ON or AFTER the closure date. Example for store 123, the ...
- 1 year ago
Try this measure:
Avg After Closing Date = VAR vTable = CALCULATETABLE ( SUMMARIZE ( 'Table', 'Table'[Str Number], 'Table'[Daily Sales] ), 'Table'[Date] >= 'Table'[Closure Date] ) VAR vResult = AVERAGEX ( vTable, 'Table'[Daily Sales] ) RETURN vResult - 1 year ago
Try adding an additional filter to exclude blank dates:
Avg After Closing Date = VAR vTable = CALCULATETABLE ( SUMMARIZE ( 'Table', 'Table'[Str Number], 'Table'[Daily Sales] ), 'Table'[Date] >= 'Table'[Closure Date], NOT ISBLANK ( 'Table'[Closure Date] ) ) VAR vResult = AVERAGEX ( vTable, 'Table'[Daily Sales] ) RETURN vResult
DataInsights
Super User
1 year ago
Try this measure:
Avg After Closing Date =
VAR vTable =
CALCULATETABLE (
SUMMARIZE ( 'Table', 'Table'[Str Number], 'Table'[Daily Sales] ),
'Table'[Date] >= 'Table'[Closure Date]
)
VAR vResult =
AVERAGEX ( vTable, 'Table'[Daily Sales] )
RETURN
vResult
jcastr02
Post Prodigy
1 year agoThank you DataInsights
Would you know also how to exclude dates where the Closure date field is blank. It seems when there is no closing date listed its pulling those values in. Thanks for your help.
- DataInsights1 year ago
Super User
Try adding an additional filter to exclude blank dates:
Avg After Closing Date = VAR vTable = CALCULATETABLE ( SUMMARIZE ( 'Table', 'Table'[Str Number], 'Table'[Daily Sales] ), 'Table'[Date] >= 'Table'[Closure Date], NOT ISBLANK ( 'Table'[Closure Date] ) ) VAR vResult = AVERAGEX ( vTable, 'Table'[Daily Sales] ) RETURN vResult