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

Join the FabCon + SQLCon recap series. Up next: Power BI, Real-Time Intelligence, IQ and AI, and Data Factory take center stage. All sessions are available on-demand after the live show. Register now

Reply
malha
Frequent Visitor

Evaluate parameter text as M code

I can filter my data using the following code in the advanced editor:

 

#"Filtered Rows" = Table.SelectRows(#"Previous step", each true)

 

Of course, nothing will happen there. What I would like to do now is to create a parameter (let's call it ParamFilter) where I could store the actual filter definition:

 

"([Column1] > 5 and [Column2] < 2)" meta [IsParameterQuery=true, Type="Any", IsParameterQueryRequired=false]

 

Now I want use that parameter content to do the actual filtering. This here will throw an error:

 

#"Filtered Rows" = Table.SelectRows(#"Previous step", each ParamFilter)

 

Which was obvious because it would be interpreted like this, mind the quotation marks:

 

#"Filtered Rows" = Table.SelectRows(#"Previous step", each "([Column1] > 5 and [Column2] < 2)")


I actually wanted to achieve this:

 

#"Filtered Rows" = Table.SelectRows(#"Previous step", each ([Column1] > 5 and [Column2] < 2))

 

So, how can I manage that? Any ideas?

 

1 ACCEPTED SOLUTION
malha
Frequent Visitor

Solved it myself after browsing the M reference again for anything related. There is the Expression.Evaluate() function. This will work:

 

#"Filtered Rows" = Table.SelectRows(#"Previous step", Expression.Evaluate(ParamFilter))

 

The each statement needs to go to the parameter value:

 

"each ([Column1] > 5 and [Column2] < 2)" meta [IsParameterQuery=true, Type="Any", IsParameterQueryRequired=false]

 

View solution in original post

1 REPLY 1
malha
Frequent Visitor

Solved it myself after browsing the M reference again for anything related. There is the Expression.Evaluate() function. This will work:

 

#"Filtered Rows" = Table.SelectRows(#"Previous step", Expression.Evaluate(ParamFilter))

 

The each statement needs to go to the parameter value:

 

"each ([Column1] > 5 and [Column2] < 2)" meta [IsParameterQuery=true, Type="Any", IsParameterQueryRequired=false]

 

Helpful resources

Announcements
April Power BI Update Carousel

Power BI Monthly Update - April 2026

Check out the April 2026 Power BI update to learn about new features.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

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.

FabCon and SQLCon Highlights Carousel

FabCon &SQLCon Highlights

Experience the highlights from FabCon & SQLCon, available live and on-demand starting April 14th.