Forum Discussion

Dalla_Terra's avatar
Dalla_Terra
Helper I
6 years ago
Solved

Calculate Rows of a Measure

  I work for a consumer product goods company and could really use some wisdom to help me get past an issue I am having.    I created a Measures table and in it I built a number of calculations to...
  • amitchandak's avatar
    6 years ago

    Dalla_Terra , This because of row context and recalculation of measure grand total. The context of Grand total is also year and input is last year, that is why you see only last year

     

    So one way out is that ytd/this year you use

    sum(Depletion[Total 9L])

     

    or try this

    new YTDTY  = Sumx(Values(Dates[Year]),[YTDTY])

  • Dalla_Terra's avatar
    6 years ago

    Thanks to you both, your feedback put me on the right path to come up with the modifications I needed to make to make my calc work. 

     

    Previously my measures were: 

    • YTDTY = TOTALYTD(sum(Depletion[Total 9L]),Dates[Date])
    • YTDLY = TOTALYTD(Sum(Depletion[Total 9L]),SAMEPERIODLASTYEAR(Dates[Date]))

    • YTD Var = [YTDTY]-[YTDLY]

    I modified my YTDTY and YTDLY as follows: 

    • YTDTY = Sumx(Values(Dates[Year]),TOTALYTD(Sum(Depletion[Total 9L]),Dates[Date]))
    • YTDLY = Sumx(Values(Dates[Year]),TOTALYTD(Sum(Depletion[Total 9L]),SAMEPERIODLASTYEAR(Dates[Date])))
     
    Leaving my YTD Var the same gave me what I was expecting to see