Problem using SUMX to iterate a table

barnettjacob

New Member
Joined
Nov 7, 2008
Messages
42
Hi,

I trying to write a measure to help me work out 'Like for Like' customer traffic in our stores. To do this I need to adjust this year's number so that I am only adding the traffic after the counter has been installed for a year.

To help me do this I have an additional column on the Store table that gives the date of the first traffic count - therefore I am aiming to filter my calendar table for dates that are 364 days greater than that number for each store.

I had hoped the measure below would work but it doesn't as the total seems to ignore the individual stores and basically uses the overall 'First Footfall' as opposed to iterating by store.

Code:
=CALCULATE(SUMX(Footfall,Footfall[traffic]),FILTER('01 - Calendar','01 - Calendar'[Date]>=min('03 - Store'[First Footfall])+364))

Any assistance would be appreciated.

Jacob
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
OK. With Rob's help I got to the answer.

The technique is detailed in his blog post here: Subtotals and Grand Totals That Add Up “Correctly” « PowerPivotPro

Effectively for the totals I had to create a measure that added the footfall just for the relevant dates then pass it through a separate SUMX to iterate it by store as desired:

Code:
[Footfall]=SUM(Footfall,Footfall[traffic])

[Adj Footfall]=CALCULATE([Footfall],FILTER('01 - Calendar','01 - Calendar'[Date]>=min('03 - Store'[First Footfall])+364))

[Footfall Fixed]=SUMX(VALUES('03 - Store'[Store]),[Adj Footfall])

I can then use this handy little COUNTROWS device to choose whether to use the standard [Footfall] measure or the one that has been iterated by store depending on whether it is a single store or a total:

Code:
[Footfall TY LFL] = 
IF(COUNTROWS(VALUES('03 - Store'[Store]))=1,
   [Footfall],
   SUMX(VALUES('03 - Store'[Store]), [Footfall Fixed])

)
Thanks Rob!!!!
 
Upvote 0
Correction:

Code:
[COLOR=#333333]
[Footfall TY LFL] = [/COLOR]IF(COUNTROWS(VALUES('03 - Store'[Store]))=1,   [Footfall],   [Footfall Fixed]) [COLOR=#333333])
[/COLOR]
 
Upvote 0

Forum statistics

Threads
1,223,933
Messages
6,175,478
Members
452,646
Latest member
tudou

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