Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago
Solved

summing the latest entry by date

Hi, 

 

I have store sales data by reporting week, but not each reporting week has data for each store. What I want to do is create a new table by reporting week that sums the sales data of the latest entry of each store in order to create a line graph by reporting week.

ROWSTORE_KEYReporting Week (a)ValueThis entry rank by store
1A201801342.991
2A2018022,608.262
3B2018022,771.601
4B20180410,613.882
5A201805852.88

3

 

 

 

Reporting Week (b)ValueCalculation explantion 1Calculation explantion 2Calculation explantion 3
201801342.99Row 1342.99 + nullonly store 2497 has entry before or equal to week 201801
2018025,379.86Row 2 + Row 32,608.26 + 2,771.60Row 1 data from 201801 is replaced by Row 2 data from 201802
2018035379.86Row 2 + Row 32,608.26 + 2,771.60No new data from 201803 so latest data from 201802 is used
20180413,222.14Row 2 + row 42,608.26 + 10,613.88, Store A's latest data is from 201802 so this is used, Store B has data from 201804 which is used
20180511,466.76Row 4 + Row 510,613.88 + 852.88Store A has data from 201805 so this is used, Store B's latest data is still from 201804

 

 

I've been succesfull in summing the sales value if Reporting week (a) from table 1 is LT or EQ to Reporting week (b) from my calculated table but this sums all values whereas I only want to sum the latest value for each STORE KEY. I've tried using measures using MAX functions of the entry rank but have been unsuccesful. help please!

2 Replies