Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
8 years ago

Parameter to switch between source queries

Hi,

 

I have two source queries containing the exact same data.

 

I have 10+ reference queries, currently referencing one of the above.

 

I created a parameter that can switch between the two source queries for each of these referenced queries.

 

So I need to switch this first part: "= #"SourceQuery1"" of each referenced query with the parameter input, but being rather new to M, I am having problems with the syntax, so initialy I just tried: "= ParameterName", which returns the current value of the parameter, but on the next steps fails, saying cannot convert value to type table.

 

So I know what the issue is, but I tried various variations of this part: "= ParameterName", but I can't seem to get the syntax right.

 

I am sure the solution is a simple one :)

 

/RSK

6 Replies

    • Anonymous's avatar
      Anonymous
      Not applicable

      Like this?

       

      let
          Source = AppInsights,
          #"Removed Other Columns" = Table.SelectColumns(Source,{"Browser"}),
          #"Removed Duplicates" = Table.Distinct(#"Removed Other Columns"),
          #"Renamed Columns" = Table.RenameColumns(#"Removed Duplicates",{{"Browser", "BrowserName"}}),
          #"Added Index" = Table.AddIndexColumn(#"Renamed Columns", "Index", 1, 1),
          #"Renamed Columns1" = Table.RenameColumns(#"Added Index",{{"Index", "BrowserID"}}),
          #"Changed Type" = Table.TransformColumnTypes(#"Renamed Columns1",{{"BrowserID", Int64.Type}})
      in
          #"Changed Type"

       

      -------------------

       

      AppInsights is my parameter name. It still gives me this error on the second step: 

       

      Expression.Error: We cannot convert the value "AppInsightsSQL (Api)" to type Table.
      Details:
          Value=AppInsightsSQL (Api)
          Type=Type

       

      --------------

       

      AppInsightsSQL (Api) is my default source query.

       

      What am I missing here?

       

      Thanks.

      • v-yuta-msft's avatar
        v-yuta-msft
        Community Support

        Hi RSK,

         

        "Expression.Error: We cannot convert the value "AppInsightsSQL (Api)" to type Table.
        Details:
            Value=AppInsightsSQL (Api)
            Type=Type"

        <--- Modify Code as pattern below and check if it can work.

        Source = Sql.Database(InstanceNames, Databases, [Query = "Select * from *"])(e.g.: InstanceNames and Databases are parameters)

        Regards,

        Jimmy Tao