Forum Discussion

Dalla_Terra's avatar
Dalla_Terra
Helper I
4 years ago
Solved

Measure Will Not Sum in Table

I know versions of this question have been posted but having gone through several examples, none are working with my issue.   Keep in mind that the YTD Sales field and the Goal field do sum on thei...
  • BA_Pete's avatar
    4 years ago

    Hi Dalla_Terra ,

     

    This is a common misunderstanding about how tables work in Power BI.

    The totals row DOES NOT sum the values in the columns above it, rather it calculates the measure in the column above it WITH NO FILTERS.

     

    Try rewriting your measures something like this:

     

    YTD Sales =
    CALCULATE(
      SUM(Depletion[Total Sales]),
      DATESYTD(Dates[Date], "31/03")  //In quotes will be the last day/month of your 'year'
    )
    
    YTD Goal =
    CALCULATE(
      SUM(Goals[Target_Goal]),
      DATESYTD(Dates[Date], "31/03")
    )
    
    Goal Achieved =
    SUMX(
      Depletion,
      VAR __achieved = [YTD Sales] / [Goal]
      RETURN
      (__achieved > 1) * __achieved
    )

     

    I've kind of done this off the top of my head as I can't see exactly how your model is set up, but the main take-away is that your table totals don't just sum the column values, so you need to use an iterator (SUMX, COUNTX etc.) around your calculation to get the individual results to sum.

     

    Pete