Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
tiprarakras
Regular Visitor

How to pass multiple selected values from a slicer to Power Query via parameter?

My datasource is a Snowflake stored procedure SP_Calc([Array])

tiprarakras_1-1717661439391.jpeg

 

I have a table called ENTITY_ATTR in which I am using a column as a slicer for the user to multiselect preferred values.

I have a parameter called paraEntity on which I have performed Bind to Parameter with ENTITY_ATTR's field.

tiprarakras_2-1717661519262.jpeg

 

tiprarakras_3-1717661527595.jpeg

 

The requirement is for the user to select value(s) from the slicer, which gets passed to the parameter, which in turn is passed as a parameter/argument to the stored procedure itself.

tiprarakras_5-1717661647741.jpeg


Here's the m-code for the SP:
let
Source = Value.NativeQuery(Snowflake.Databases("servername.com","warehouse_name",[Role="role_name"])
{[Name="database_name"]}[Data], "CALL DBO.SP_Calc(['"& paraEntity &"']", null, [EnableFolding=false])
in
Source

 

If all goes well, the stored proc which gets passed to Snowflake will look like this: CALL DBO.SP_Calc( ['selection1', selection2', 'selection3'] )


This works for single slicer selection, but if I turn it to multi select, then it gives the error "We cannot apply operator &  to types Text and List."

tiprarakras_6-1717661811940.jpeg

 

Please help with this problem, as it's quite urgent!

@amitchandak @ChandeepChhabra @NotGregDeckler 

5 REPLIES 5
jennratten
Super User
Super User

 Hi @tiprarakras - when you make the slicer multi-select, the value of the parameter turns into a list since it is no longer one value.  Your parameter shows it is set as type text and this is confirmed by the error message.  You will need to include some additional steps in Power Query to handle this conversion of the list selected in the report.  Here is a good example:

let
  EntityList = 
    if 
    //check to see if the parameter is a list
      Type.Is(
        Value.Type(paraEntity), 
        List.Type
      ) then 
        //if it is a list
        let
          //add single quotes around each value in the list
          AddSingleQuotes = List.Transform(
              paraEntity, 
              each "'" & _ & "'"
            ),
          //then turn it into a comma-delimited list
          DelimitedList = Text.Combine(
              AddSingleQuotes, 
              ","
            )
        in
          DelimitedList
    else 
      //if the parameter isn't a list
      //just add single quotes around the parameter value
      "'" & paraEntity & "'",
  //generate and run the query
Source = Value.NativeQuery(Snowflake.Databases("servername.com","warehouse_name",[Role="role_name"])
{[Name="database_name"]}[Data], "CALL DBO.SP_Calc(['"& EntityList &"']", null, [EnableFolding=false])
in
Source

https://learn.microsoft.com/en-us/power-bi/connect-data/desktop-dynamic-m-query-parameters 

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

Hi @jennratten 
First of all, thank you so much for meticulously looking into this!

However I am getting the following error:

tiprarakras_1-1717707294278.png

 

'All' is actually the default value I have set for my paraEntity parameter.
Could this be caused by queryfolding=false I have set? I need to have it as false, or power query throws a syntax error at the CALL command. 

 

You're welcome!  It's hard to say the reason without seeing the revised script.  I don't think it would be related to query folding = false though.  Can you please send your revised script?

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

Hi @jennratten 

Please find below my updated script:

let
EntityList =
if
//check to see if the parameter is a list
Type.Is(
Value.Type(paraEntity),
List.Type
) then
//if it is a list
let
//add single quotes around each value in the list
AddSingleQuotes = List.Transform(
paraEntity,
each "'" & _ & "'"
),
//then turn it into a comma-delimited list
DelimitedList = Text.Combine(
AddSingleQuotes,
","
)
in
DelimitedList
else
//if the parameter isn't a list
//just add single quotes around the parameter value
"'" & paraEntity & "'",
//generate and run the query
Source = Value.NativeQuery(Snowflake.Databases("servername.com","warehouse_name",[Role="role_name"])
{[Name="database_name"]}[Data], "CALL DBO.SP_Calc('ABCXYZ', ['"& EntityList &"'], ['All'], ['All'], 'LC', ['22-Jan'], ['All'], ['Actual'], ['All'], ['All'])", null, [EnableFolding=false])
in
Source

 

Just to add some context - paraEntity is just one of the parameters I am using to take create a slicer out of a table. There are more user-selectable dropdowns bound to other parameters I have created that get passed to the stored proc (but I am hardcoding their value as 'All' for the moment).

tiprarakras
Regular Visitor

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.