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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
karunpoudel
Regular Visitor

Query folding (Table.View) handler function to filter rows/add where clause

I am building a custom connector and need to implement query folding when filter is added. What is the On* handler function name and its parameters for this? Is there any documentation on this and all available handler functions?

These doc doesn't contain everything.
https://learn.microsoft.com/en-us/power-query/samples/trippin/10-tableview1/readme

https://learn.microsoft.com/en-us/power-query/power-query-folding

 

1 ACCEPTED SOLUTION
karunpoudel
Regular Visitor

The handler is

OnSelectRows = (condition as function) =>
    let
        ast = RowExpression.From(condition),
        ...

We can convert the condition into abstract syntax tree (AST) using:

RowExpression.From(function as function) as record

Example:
For 

Table.SelectRows(table, each [Metric1]>=2000 or [Metric1]=null or [Metric1]=[Metric2])

AST is :

[ Kind = "Binary", Operator = "Or", 
  Left = [ Kind = "Binary", Operator = "Or", 
           Left = [ Kind = "Binary", Operator = "GreaterThanOrEquals",
                    Left = [ Kind = "FieldAccess", MemberName = "Metric1", Expression = RowExpression.Row  ] , 
                    Right = [ Kind = "Constant", Value = 2000 ]
                   ] , 
           Right = [ Kind = "Binary", Operator = "Equals", 
                     Left = [ Kind = "FieldAccess", MemberName = "Metric1", Expression = RowExpression.Row  ] , 
                     Right = [ Kind = "Constant", Value = null ]  
                    ]  
          ] , 
  Right = [ Kind = "Binary", Operator = "Equals", 
            Left = [ Kind = "FieldAccess", MemberName = "Metric1", Expression = RowExpression.Row  ] , 
            Right = [ Kind = "FieldAccess", MemberName = "Metric2", Expression = RowExpression.Row  ]  
           ]  
 ]​

View solution in original post

2 REPLIES 2
karunpoudel
Regular Visitor

The handler is

OnSelectRows = (condition as function) =>
    let
        ast = RowExpression.From(condition),
        ...

We can convert the condition into abstract syntax tree (AST) using:

RowExpression.From(function as function) as record

Example:
For 

Table.SelectRows(table, each [Metric1]>=2000 or [Metric1]=null or [Metric1]=[Metric2])

AST is :

[ Kind = "Binary", Operator = "Or", 
  Left = [ Kind = "Binary", Operator = "Or", 
           Left = [ Kind = "Binary", Operator = "GreaterThanOrEquals",
                    Left = [ Kind = "FieldAccess", MemberName = "Metric1", Expression = RowExpression.Row  ] , 
                    Right = [ Kind = "Constant", Value = 2000 ]
                   ] , 
           Right = [ Kind = "Binary", Operator = "Equals", 
                     Left = [ Kind = "FieldAccess", MemberName = "Metric1", Expression = RowExpression.Row  ] , 
                     Right = [ Kind = "Constant", Value = null ]  
                    ]  
          ] , 
  Right = [ Kind = "Binary", Operator = "Equals", 
            Left = [ Kind = "FieldAccess", MemberName = "Metric1", Expression = RowExpression.Row  ] , 
            Right = [ Kind = "FieldAccess", MemberName = "Metric2", Expression = RowExpression.Row  ]  
           ]  
 ]​
ppm1
Solution Sage
Solution Sage

Here is an article that may help explain further.

Chris Webb's BI Blog: Speed Up Data Refresh Performance In Power BI Desktop Using Table.View (crossj...

 

Pat

Microsoft Employee

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors
Top Kudoed Authors