Good morning
I am unsure if what I am about to ask is even feasible however it is currently the only way I can think to populate information moving forwards without having to manually update formulas each month to correct the values.
In essence what I am trying to get to is displaying quarterly average over a period of 2 Years historical data.
The SQL Table / Code I am trying to manipulate is detailed as follows:
SELECT [Stock No], [Sales Qty 1 ], [Sales Qty 2 ], [Sales Qty 3 ], [Sales Qty 4 ], [Sales Qty 6 ], [Sales Qty 5 ], [Sales Qty 7 ], [Sales Qty 8 ], [Sales Qty 10 ], [Sales Qty 9 ],
[Sales Qty 11 ], [Sales Qty 12 ], [Sales Qty 13 ], [Sales Qty 14 ], [Sales Qty 15 ], [Sales Qty 16 ], [Sales Qty 17 ], [Sales Qty 18 ], [Sales Qty 19 ], [Sales Qty 20 ],
[Sales Qty 22 ], [Sales Qty 21 ], [Sales Qty 23 ], [Sales Qty 24 ]
FROM dbo.KPIREPORT
I have then generated an excel sheet that auto generates the correct period of dates automatically based on "todays date" as follows. (This has also been dumped into SQL (table name : dbo.'Field Names$'
Field Name Month Quarter
Sales Qty 1 1 Q1
Sales Qty 2 12 Q4
Sales Qty 3 11 Q4
Sales Qty 4 10 Q4
Sales Qty 5 9 Q3
Sales Qty 6 8 Q3
Sales Qty 7 7 Q3
Sales Qty 8 6 Q2
Sales Qty 9 5 Q2
Sales Qty 10 4 Q2
Sales Qty 11 3 Q1
Sales Qty 12 2 Q1
Sales Qty 13 1 Q1
Sales Qty 14 12 Q4
Sales Qty 15 11 Q4
Sales Qty 16 10 Q4
Sales Qty 17 9 Q3
Sales Qty 18 8 Q3
Sales Qty 19 7 Q3
Sales Qty 20 6 Q2
Sales Qty 21 5 Q2
Sales Qty 22 4 Q2
Sales Qty 23 3 Q1
Sales Qty 24 2 Q1
Is there any feasible way to link the headings in dbo.KPIREPORT to the this table so that I can then sum the historical quarters and work out a historical average of those periods?
If you require any further information please let me know.
I am in the process of trying to understand SQL so please go easy on me!
Thanks for your time.
I am unsure if what I am about to ask is even feasible however it is currently the only way I can think to populate information moving forwards without having to manually update formulas each month to correct the values.
In essence what I am trying to get to is displaying quarterly average over a period of 2 Years historical data.
The SQL Table / Code I am trying to manipulate is detailed as follows:
SELECT [Stock No], [Sales Qty 1 ], [Sales Qty 2 ], [Sales Qty 3 ], [Sales Qty 4 ], [Sales Qty 6 ], [Sales Qty 5 ], [Sales Qty 7 ], [Sales Qty 8 ], [Sales Qty 10 ], [Sales Qty 9 ],
[Sales Qty 11 ], [Sales Qty 12 ], [Sales Qty 13 ], [Sales Qty 14 ], [Sales Qty 15 ], [Sales Qty 16 ], [Sales Qty 17 ], [Sales Qty 18 ], [Sales Qty 19 ], [Sales Qty 20 ],
[Sales Qty 22 ], [Sales Qty 21 ], [Sales Qty 23 ], [Sales Qty 24 ]
FROM dbo.KPIREPORT
I have then generated an excel sheet that auto generates the correct period of dates automatically based on "todays date" as follows. (This has also been dumped into SQL (table name : dbo.'Field Names$'
Field Name Month Quarter
Sales Qty 1 1 Q1
Sales Qty 2 12 Q4
Sales Qty 3 11 Q4
Sales Qty 4 10 Q4
Sales Qty 5 9 Q3
Sales Qty 6 8 Q3
Sales Qty 7 7 Q3
Sales Qty 8 6 Q2
Sales Qty 9 5 Q2
Sales Qty 10 4 Q2
Sales Qty 11 3 Q1
Sales Qty 12 2 Q1
Sales Qty 13 1 Q1
Sales Qty 14 12 Q4
Sales Qty 15 11 Q4
Sales Qty 16 10 Q4
Sales Qty 17 9 Q3
Sales Qty 18 8 Q3
Sales Qty 19 7 Q3
Sales Qty 20 6 Q2
Sales Qty 21 5 Q2
Sales Qty 22 4 Q2
Sales Qty 23 3 Q1
Sales Qty 24 2 Q1
Is there any feasible way to link the headings in dbo.KPIREPORT to the this table so that I can then sum the historical quarters and work out a historical average of those periods?
If you require any further information please let me know.
I am in the process of trying to understand SQL so please go easy on me!
Thanks for your time.