Forum Discussion
Avoid skipping empty rows when SUMMARIZE table with zero records in the source
- 2 years ago
I would start with a full set of weeks and then calculate amount along these lines:
Average weekly business won volume = VAR _FullWeeks_ = VALUES ( Calendar[Week number] ) VAR _Avg = AVERAGEX ( _FullWeeks_, CALCULATE ( SUM ( BusinessCases[Ammount] ), BusinessCases[Status] = "Won", BusinessCases[Date type] = "Closed" ) + 0 ) RETURN _AvgYou might need something more sophisticated for _FullWeeks_ as I'm not sure how the min and max week numbers are determined in your scenario.
please try
Average weekly business won volume =
AVERAGEX (
SUMMARIZE (
FILTER (
BusinessCases,
BusinessCases[Status] = "Won"
&& BusinessCases[Date type] = "Closed"
),
Calendar[Week number],
"SummarizedResult", SUMX ( BusinessCases, BusinessCases[Ammount] )
),
[SummarizedResult] + 0
)
Hi tamerj1 ,
thank you for your suggestion. These were my first ideas of the solution too, but unfortunately this does not work 😞
Suggested solution adds 0 to every single row generated by the SUMMARIZE function, but unfortunately does not force SUMMARIZE function to avoid ommiting rows for weeks with no records.
When I use my example, the suggested solution results in following - week number 2 still missing:
| Week number | SummarizedResult |
| 1 | 6000 + 0 |
| 3 | 4000 + 0 |
| 4 | 2000 + 0 |
| Weekly average | 4000 |
- AlexisOlson2 years ago
Super User
I would start with a full set of weeks and then calculate amount along these lines:
Average weekly business won volume = VAR _FullWeeks_ = VALUES ( Calendar[Week number] ) VAR _Avg = AVERAGEX ( _FullWeeks_, CALCULATE ( SUM ( BusinessCases[Ammount] ), BusinessCases[Status] = "Won", BusinessCases[Date type] = "Closed" ) + 0 ) RETURN _AvgYou might need something more sophisticated for _FullWeeks_ as I'm not sure how the min and max week numbers are determined in your scenario.
- jakubalbrecht2 years ago
Helper I
Thank you, AlexisOlson , works perfectly.
- tamerj12 years ago
Community Champion
Average weekly business won volume =
AVERAGEX (
VALUES ( Calendar[Week number] ),
CALCULATE (
SUM ( BusinessCases[Ammount] ),
FILTER (
BusinessCases,
BusinessCases[Status] = "Won"
&& BusinessCases[Date type] = "Closed"
)
) + 0
)- jakubalbrecht2 years ago
Helper I
Hello tamerj1 , thank you very much for the update. We are pretty close - for every single week the calculation works as expected (incl. 0 values instead of skipped rows) but the final average return the sum of the weekly values instead of average values.
But modificated solution provided by AlexisOlson bellow (ommited FILTER function) works perpectly.
Thank you very much to both of you!