Forum Discussion
summarize not considering blank rows
I have a dax that calculate the average sales of selected sales team - summarize will not return a record for territories that have no revenue, though in below its checking 0 and null. I need these 0 value territories to be included otherwise the average is inflated. In the data model, "sales" is the fact table that glues all the dimension tables. So
M_Rev_DisplayAvg =
var Vals = CALCULATETABLE(
ADDCOLUMNS (
SUMMARIZE(Sales,
SalesHier[Territory Name],
DateTable[Year-Mon],
'Prod Mapping - MaterialOrSegment'[MBR Financials]),
"Rev", if([M_TotalRevPlanRate]=0 || ISBLANK([M_TotalRevPlanRate]), 0, [M_TotalRevPlanRate])),
ALLSELECTED ())
VAR AvgValue = AVERAGEX ( Vals, [Rev] )
Return AvgValue
Thank you so much in advance!
NM
6 Replies
- az38
Community Champion
Hi nanma94
I don't like ypur summarize statement
SUMMARIZE(Sales, SalesHier[Territory Name], DateTable[Year-Mon], 'Prod Mapping - MaterialOrSegment'[MBR Financials])It should have a little bit other syntax https://docs.microsoft.com/en-us/dax/summarize-function-dax
it has no "name" argument
- az38
Community Champion
as I understand its name "M_TotalRevPlanRate"?
why do you need calculatetable?
M_Rev_DisplayAvg = var Vals = ADDCOLUMNS ( SUMMARIZE(Sales, SalesHier[Territory Name], DateTable[Year-Mon], "M_TotalRevPlanRate", 'Prod Mapping - MaterialOrSegment'[MBR Financials]), "Rev", if(ISBLANK([M_TotalRevPlanRate]), 0, [M_TotalRevPlanRate])) VAR AvgValue = AVERAGEX ( Vals, [Rev] ) Return AvgValueworks pretty good for my dummy data
- v-lionel-msft
Community Support
Hi nanma94 ,
Has your problem been solved?
Best regards,
Lionel ChenIf this post helps, then please consider Accept it as the solution to help the other members find it more quickly.