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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
Mr_Glister
Advocate II
Advocate II

Using parameter to dynamically call a query step - Not working

Hi,

is it possible to use a parameter to call a step in the query?

There is a filtering step in my query, that on a few occasions I want to disable. My idea was to create a parameter which contains the string value of one of the two previous step names, so that I can choose whether I want my query to use the filtered table, or the un-filtered one (from the step previous to the filter step). 

But I'm getting the following error: Expression.Error: We cannot convert the value "#"Filtered Rows"" to type Table.

 

I'm showing an example script below. 

 

 

 

Example:

 

Mr_Glister_2-1678110130747.png

let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WciwoyElV0lEKSk1RAFKGOiZKsTrRSk6JeUAIFIhMzcnJLwcyDHTMTcFS/kWJeekgLXCGEVg8IKc0F2GQgY4RUHksAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Fruit = _t, Color = _t, Price = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Fruit", type text}, {"Color", type text}, {"Price", type number}}),
#"Sorted Rows" = Table.Sort(#"Changed Type",{{"Fruit", Order.Ascending}}),
#"Filtered Rows" = Table.SelectRows(#"Sorted Rows", each ([Color] = "Red ")),
#"Multiplied Column" = Table.TransformColumns(#"Filter OnOff", {{"Price", each _ * 1.2, type number}})
in
#"Multiplied Column"

 

Mr_Glister_1-1678110085405.png

 

 

 

 

1 ACCEPTED SOLUTION
AntrikshSharma
Community Champion
Community Champion

@Mr_Glister 

 

let
    Source = Table.FromRows (
        Json.Document (
            Binary.Decompress (
                Binary.FromText (
                    "i45WciwoyElV0lEKSk1RAFKGOiZKsTrRSk6JeUAIFIhMzcnJLwcyDHTMTcFS/kWJeekgLXCGEVg8IKc0F2GQgY4RUHksAA==",
                    BinaryEncoding.Base64
                ),
                Compression.Deflate
            )
        ),
        let
            _t = ( ( type nullable text ) meta [ Serialized.Text = true ] )
        in
            type table [ Fruit = _t, Color = _t, Price = _t ]
    ),
    ChangedType = Table.TransformColumnTypes (
        Source,
        { { "Fruit", type text }, { "Color", type text }, { "Price", type number } }
    ),
    SortedRows = Table.Sort ( ChangedType, { { "Fruit", Order.Ascending } } ),
    FilteredRows = Table.SelectRows ( SortedRows, each ( [Color] = "Red " ) ),
    MultipliedColumn = Table.TransformColumns (
        if DoSomething = "FilteredRows" 
        then FilteredRows 
        else 
            if DoSomething = "SortedRows" 
            then SortedRows
            else ChangedType,
        { { "Price", each _ * 1.2, type number } }
    )
in
    MultipliedColumn

 

AntrikshSharma_0-1678119358623.png

 

View solution in original post

2 REPLIES 2
AntrikshSharma
Community Champion
Community Champion

@Mr_Glister 

 

let
    Source = Table.FromRows (
        Json.Document (
            Binary.Decompress (
                Binary.FromText (
                    "i45WciwoyElV0lEKSk1RAFKGOiZKsTrRSk6JeUAIFIhMzcnJLwcyDHTMTcFS/kWJeekgLXCGEVg8IKc0F2GQgY4RUHksAA==",
                    BinaryEncoding.Base64
                ),
                Compression.Deflate
            )
        ),
        let
            _t = ( ( type nullable text ) meta [ Serialized.Text = true ] )
        in
            type table [ Fruit = _t, Color = _t, Price = _t ]
    ),
    ChangedType = Table.TransformColumnTypes (
        Source,
        { { "Fruit", type text }, { "Color", type text }, { "Price", type number } }
    ),
    SortedRows = Table.Sort ( ChangedType, { { "Fruit", Order.Ascending } } ),
    FilteredRows = Table.SelectRows ( SortedRows, each ( [Color] = "Red " ) ),
    MultipliedColumn = Table.TransformColumns (
        if DoSomething = "FilteredRows" 
        then FilteredRows 
        else 
            if DoSomething = "SortedRows" 
            then SortedRows
            else ChangedType,
        { { "Price", each _ * 1.2, type number } }
    )
in
    MultipliedColumn

 

AntrikshSharma_0-1678119358623.png

 

Thanks! I will accept this as a solution. 

But do you think there would be a more elegant solution? In order to do what you suggest I have to maintain the manual string of the step names in two places, both in the list of values in the parameter and then in the actual script again. 

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Fabric Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.