I want to be able to define my parameter SA.FiscalWeek in the below code from a cell in Excel
SUM(CASE WHEN SA.FISCALYEAR = 2017
AND SA.FISCALWEEK = 19 THEN
You can use vba to pass the query to the command text, Use a helper sheet with your query listed line by line
=" line 1 of query"
=" line 2 etc. "
=" line 3&E4&"rest of line etc. "
E4 would be a cell ref to make the query dynamic from Excel then concatenate these lines into one cell,
use vba similiar to the below, my range "SQLCOUNTRY" is the cell of concatenated query
With ActiveWorkbook.Connections("EUUKSQL01 dashboard StockSalesAggregateWeek2") _
.OLEDBConnection
.CommandText = Sheets("CountryScript").Range("SQLCOUNTRY").Value
End With
This way any part of the query can be driven off an existing excel Cell