Quantcast
Channel: SQL Server Reporting Services, Power View forum
Viewing all articles
Browse latest Browse all 20764

12 WEEK AVERAGE

$
0
0

Hi Folks,

I am really stuck at this problem. So please help me.

I am trying to find 12 week average for a store and that average should be based on the same weekday for last 12 weeks. Average = Total Net for 12 weeks/ 12. But if any of the 12 weekdays has no Sales then the average should be Total Net for 12 weeks/ 11 (if there is no sales for one weekday).

Below is my query,

SELECT     System_DateJoined.StoreKey, System_DateJoined.RestaurantName, System_DateJoined.Ownership,
                      System_DateJoined.LeaseEagle_ID, System_DateJoined.State, System_DateJoined.DateKey,
CASE WHEN DimLFL.Commentary = 'New Store' THEN 'Category 1 - New Store as flagged in LFL File'
WHEN DimLFL.Commentary = 'Mjr Reno' THEN 'Category 2 - Reno as flagged in LFL File'
WHEN DimLFL.Commentary = 'Min Reno' THEN 'Category 2 - Reno as flagged in LFL File'
WHEN DimLFL.Commentary = 'Temp Close' THEN 'Category 3 - Temp Closure'
WHEN ISNULL(Daily_Sales_Summary.[LastWeek_Net],1) <= 1 THEN 'Category 7 - Missing Data for Last Week'
WHEN ISNULL(Nandos_Daily_Sales_Summary.Net, 1) <= 1 THEN 'Category 4 - Missing Data'
WHEN ISNULL(Daily_Sales_Summary.LastYear_Net, 1) <= 1 THEN 'Category 6 - No sales last year'
ELSE
'Category 5 - Potential Over/Under stated sales'
END as Category,

Daily_Sales_Summary.Net, Daily_Sales_Summary.[LastWeek_Net], Daily_Sales_Summary.LastYear_Net
       ,Daily_Sales_Summary.TransactionCount,Daily_Sales_Summary.[LastWeek_TransactionCount]
       ,Daily_Sales_Summary.LastYear_TransactionCount, Nandos_Daily_Sales_Summary.[12Week_TransactionCount], System_DateJoined.FullDate,
                      System_DateJoined.DayNameOfWeek, System_DateJoined.FinancialWC, System_DateJoined.strFinancialWeek, DimLFL.Commentary
FROM         Daily_Sales_Summary RIGHT OUTER JOIN
                      System_DateJoined LEFT OUTER JOIN
                      DimLFL ON System_DateJoined.StoreKey = DimLFL.StoreKey AND System_DateJoined.DateKey = DimLFL.DateKey ON 
                      Daily_Sales_Summary.RID = System_DateJoined.StoreKey AND 
                      Daily_Sales_Summary.DateKey = System_DateJoined.DateKey

How can I do the 12 week average.

If you have any queries please let me know.


shivangdesai



Viewing all articles
Browse latest Browse all 20764

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>