Forum Discussion
Previous Week Calculations
- 8 years ago
OK, this needs a little explaination. See some sample data I created based on your input (Screen Shot 1).
The same formula works based on FACT Vol values with dates, cities, Disctricts, etc. (Screen shot 3) ** BUT ** you can't summarize AT2_PW_VOL_2 b/c it's a GROUP calcualtion by Week already...
AT2_PW_VOI_2 = CALCULATE(SUM('Activity Table 2'[VOL]), FILTER(ALLSELECTED('Activity Table 2'), 'Activity Table 2'[Calc_Week] = (EARLIER('Activity Table 2'[Calc_Week]) - 1) && 'Activity Table 2'[District] = EARLIER('Activity Table 2'[District])))
Now the 'why' it works... See my 2nd screen shot where i Un-Sumed VOL. Even though '-43' is the correct SUM'ED Total for VOL for the previous week for ON WWW, -43 isn't a SUM'ed value it's really -43 OVER AND OVER AND OVER again for the whole week. As such, 'SUM'ing this column again throws off your numbers.
Side note! I'm assuming you will want to do some form of Delta or % change calcuation. But remember these are columns and not measures, so you have to use something like MAX or AVG with the AT2_PW_VOL_2 column not to throw off your numbers again. Since EVERY entry in AT2_PW_VOL_2 for the week (by district) is the same, it really doesn't matter what you use when creating your follow-up Measures. (AVG might be safer actually?)
DELTA = SUM('Activity Table 2'[VOL]) - MAX('Activity Table 2'[AT2_PW_VOI_2])
Hope this helps!
FOrrest
P.S. A little ISBLANK logic on DELTA will keep your week 1 from looking wrong. :-)
Just taking benefit from your in-depth knowledge here, why can't the same thing be achieved from Measures? why do we need to create columns?
There are ways to create measures to do the same thing, Google DAX EARLIER AS a Measure for examples. Everyone's programming style is different; no right or wrong way to do things, just how I perfer to go at a solution.