Forum Discussion

shaunwilks's avatar
shaunwilks
Helper V
8 years ago
Solved

Dynamic Data Source based on parameter

  Hello all,   Hopefully this is easier to explain that Im finding it is to do.   I have done work with parameters that place the SQL Server and Database names into the Source in the Advanced Ed...
  • Anonymous's avatar
    Anonymous
    8 years ago

    shaunwilks,

    Here is an example for you.

    let
    
    #"Table 1" = (para as text) =>
    if para = "test1"
    then
    
    let
        Source = Sql.Database("servername", "test",[Query="select * from Main"])
       in
        Source
    
    else 
    
    let
        Source = Excel.Workbook(File.Contents("path\Book1.xlsx"), null, true),
        #"Security public - Copy_Sheet" = Source{[Item="Security public - Copy",Kind="Sheet"]}[Data]
        in
        #"Security public - Copy_Sheet"
    
    in #"Table 1"



    Regards,
    Lydia