Having trouble getting a previous period calculation - help?

sherifffruitfly

New Member
Joined
Dec 21, 2013
Messages
8
hi all,

i have a powerpivot table Sales with a column Week (just an integer, counting up from when I started keeping track of data), and a column SalesAmount.

there aren't any dates, just the incrementing week number.

i have a measure that sums over SalesAmount - this let's me look at any slicer-ed week's sales in my pivot table.

i would like another measure that gives the SalesAmount for the prior week (i.e. those rows whose Week number is 1 less than the current row's).

googling around, i ended up trying this:

1) create a new table WeeksTable with a column Weeks, with values just being incrementing whole numbers

2) back in the Sales table, add a new column SalesPrevWeek, defined by the formula:

=CALCULATE(sum([SalesAmount]), WeeksTable[WeekNumber] - 1)

(the sum is there because powerpivot didn't recognize the column without it, and googling suggested summing or otherwise aggregating)


3) on the Sales table, create a measure summing over SalesPrevWeek

this seems to not give me previous weeks' sales amounts - rather it shows current week totals.

what am i missing here?

thanks for any tips,
sff
 
Last edited:

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
you almost had it!

=CALCULATE(sum([SalesAmount]), FILTER( ALL(WeeksTable), WeeksTable[WeekNumber] - 1 = MAX( WeeksTable[WeekNumber] ) )

TRY IT!!!
 
Upvote 0

Forum statistics

Threads
1,223,970
Messages
6,175,726
Members
452,667
Latest member
vanessavalentino83

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top