Forum Discussion

Feilin's avatar
Feilin
Helper II
8 years ago
Solved

Source with parameters/queries

I would like to add parameters or queries into my source when I import. I tried: let Source = Excel.Workbook(File.Contents(#"Folder"&"\invoices"& #"Date"&".xls"), null, true), [...] where Fold...
  • Feilin's avatar
    8 years ago

    I found the solution!

     

    Apparently it had to do with types. Even though I had it set to text, it didn't work, but when I set it to number and converted to text, it worked.

    let
        Source = AnalysisServices.Database(
    	"name",
    	"name",
    		[Query=SELECT [Date].[Year].&["& Number.ToText(CurrentYear) &"]"
    [...]

    It works with formulas and/or calculations as well, so long as it is converted to text:

    let
        Source = AnalysisServices.Database(
    	"name",
    	"name",
    		[Query=SELECT [Date].[Year].&["& Number.ToText( Date.Year( DateTime.LocalNow() - 1) &"]"
    [...]

    Thanks for the hints!