I’m trying to pull data from SQL and use a dynamic reference within the excel workbook. The query works fine if I hardcode the Yr reference in the WHERE statement, so I think it has something to do with that. I’m pretty good and SQL and know this query works there, but was trying to write it to pull directly into excel instead of copying it over.
= Sql.Database(“server”, “database”, [Query=”SELECT [State],[Yr],sum([dollars]) ‘dollars’ FROM [table] WHERE Yr ='”Excel.CurrentWorkbook(){[Name=”Year”]}[Content]{0}[Column1]”‘”])