Forum Discussion

biguy34965's avatar
biguy34965
Frequent Visitor
1 year ago
Solved

Dataflow parameter code addition to the source line

I have a dataflow that uses Starburst ODBC.  The parameter was created using a list. The list includes 2 different data sources. Having trouble changing the source line in Advanced Editor to accomoda...
  • v-kpoloju-msft's avatar
    1 year ago

    Hi biguy34965,
    Thank you for reaching out to the Microsoft fabric community forum.

    I understand you are trying to make your dataflow more dynamic by using a parameter instead of hardcoding the Starburst data source in the Advanced Editor. You are on the right track just a small step is needed to get it working.

    The StarburstPresto.Contents() function expects a single text value (like a server name), but your parameter "Starburst Data Source" is a list. So, before using it in the function, you need to pick one item from that list.

    Update your M code like this:

    let
    
      SelectedSource = #"Starburst Data Source"{0},
    
      Source = StarburstPresto.Contents(SelectedSource, 443, null),
    
      #"Navigation 1" = Source{[Name = "thedatabasename", Kind = "Database"]}[Data],
    
      #"Navigation 2" = #"Navigation 1"{[Name = "the schemaname", Kind = "Schema"]}[Data],
    
      #"Navigation 3" = #"Navigation 2"{[Name = "thetablename", Kind = "Table"]}[Data]
    
    in
    
      #"Navigation 3"

    You can change (0) to (1) if you want to use the second data source in the list.

    Make sure your parameter is defined as a list of text values. If you want users to choose the source dynamically (like from a dropdown), consider using a text parameter instead of a list, or create a helper query to select the item.

    Also, please refer to the below mentioned documentation link for more information:
    Dynamic M query parameters in Power BI Desktop - Power BI | Microsoft Learn
    Parameters - Power Query | Microsoft Learn

    Hope this helps clarify things and let me know what you find after giving these steps a try happy to help you investigate this further.

    Thank you for using the Microsoft Fabric Community Forum.