Forum Discussion

Emma_'s avatar
Emma_
Helper II
5 months ago
Solved

Power Query Parameters Selected Value in a Table / Report View

Hi everyone, I am using a parameter in Power BI to control from which data source I load the data before loading it into the model (for example: Source Environement Preprod vs Prod). This works fi...
  • jennratten's avatar
    5 months ago

    Hello Emma_ - thanks for posting in the Fabric Community.  

    Below is one way you can get the outcome you are expecting.  Please let me know if you have any questions.

    In this example I am creating a table which displays the email addresses from the parameter paramTesterEmails split into separate rows (one per email), with two additonal columns populated by the parameters paramTesterRoleId and paramClientEntityId.

     

    Parameters in Power Query:

     

    Create a new function:

    For your use case you can simply replace the parameter names with your real parameter names as well as what you'd like your columns to be named.

    let
        fn = ( ) =>
    let
        Source = Text.Split(paramTesterEmails,","),
        ListToTable = Table.FromList(Source, Splitter.SplitByNothing(), {"UPN"}, null, ExtraValues.Error),
        ChangeTypes = Table.TransformColumnTypes(ListToTable,{{"UPN", type text}}),
        AddId = Table.AddColumn(ChangeTypes, "TesterRoleId", each paramTesterRoleId, Int64.Type),
        ClientEntityId = Table.AddColumn ( AddId, "ClientEntityId", each paramClientEntityId, Int64.Type )
    in
        ClientEntityId
    in
        fn

     Then invoke the function to produce the table:

     

    If this post helps to answer your questions, please consider marking it as a solution so others can find it more quickly when faced with a similar challenge.

    Proud to be a Microsoft Fabric Super User