Forum Discussion

AlvinB's avatar
AlvinB
Frequent Visitor
1 year ago
Solved

Variable source connection in DataFlow

Hi all, I want to achieve to load tables from variable source like below. I set the parameters for source connection and was using those to load tables but I got many DataFlows and it's a burdent t...
  • BA_Pete's avatar
    1 year ago

    Hi AlvinB ,

     

    I'm not sure I fully understand your requirements to be honest, but here's what I think you're aiming for:

    let
      // Below is your dataflow for controlling whether you want DEV or PROD data in your query
      // I assume this just a single value, 1 or 0, to flag whether you want PROD or DEV source
      // It can be set up as follows:
      // let
      //   Source = 0,  // or 1 for PROD
      //   convToTable = Table.FromValue(Source)
      // in
      //  convToTable
    
      Param_dataflow = PowerPlatform.Dataflows(),
      Param_Workspaces = Source_dataflow{[Id = "Workspaces"]}[Data],
      Param_Workspace = Workspaces{[workspaceId = WorkspaceID]}[Data],
      Param_Dataflow = Workspace{[dataflowId = DataflowID]}[Data],
      Param_Value = Dataflow{[entity = "Parameter_On_off"]}[Data],
      // End get parameter value
    
      // Get DEV source
      DEV_dataflow = PowerPlatform.Dataflows(),
      DEV_Workspaces = Source_dataflow{[Id = "Workspaces"]}[Data],
      DEV_Workspace = Workspaces{[workspaceId = WorkspaceID]}[Data],
      DEV_Dataflow = Workspace{[dataflowId = DataflowID]}[Data],
      DEV_Table = Dataflow{[entity = "Configuration"]}[Data],
      // End get DEV source
    
      // Get PROD source
      PROD_Source = Databricks.Catalogs(HostName1, "/sql/100/kkkhouse/somenumbers", [Catalog = null, Database = null, EnableAutomaticProxyDiscovery = "enabled"]),
      PROD_Database = Source{[Name = "catalog_name", Kind = "Database"]}[Data],
      PROD_Schema = PROD_Database{[Name = "schema_name", Kind = "Schema"]}[Data],
      PROD_Table = PROD_Schema{[Name = "table_name", Kind = "Table"]}[Data],
      // End get PROD source
    
      // Select DEV or PROD source
      SelectedSource = if Param_Value[Value]{0} = 0 then DEV_Table else PROD_Table
    in
      SelectedSource

     

    Pete