Forum Discussion

nanma94's avatar
nanma94
Icon for Helper III rankHelper III
6 years ago

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

    • nanma94's avatar
      nanma94
      Icon for Helper III rankHelper III

      az38Thank you! I will add the names. But will the names fix the issue... 🙂

      • az38's avatar
        az38
        Icon for Community Champion rankCommunity Champion

        nanma94 

        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 AvgValue

        works pretty good for my dummy data

  • v-lionel-msft's avatar
    v-lionel-msft
    Icon for Community Support rankCommunity Support

    Hi nanma94 ,

     

    Has your problem been solved?

     

    Best regards,
    Lionel Chen

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.