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

Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now

Reply
brassy27
New Member

Dynamically filtering a structured column (Table) using a condition stored in another column

I've been busting my head for a few days and cannot seem to accomplish what I feel should be a trivial task.

 

I have a table with one of the columns being a structured column (Table) looking like this:

2022-11-07_9-34-16.jpg

Fig. 1

 

The same table has another basic text column containing:

2022-11-07_9-35-44.jpg 

Fig. 2

 

I'd like to create a new column with the Custom2 (Fig. 1) content filtered by the PerformanceIndicatorsParsed (Fig. 2).

 

Expected result for 1st row:

2022-11-07_9-53-49.jpg

For 4th row:

2022-11-07_9-54-16.jpg

 

Here is the code:

 

let
   filter_indicator = () =>
   let
      output = [PerformanceIndicatorParsed]
   in
      output,

   Filtered = Table.SelectRows([Custom2], filter_indicator()),
   Result = Table.FirstN(Filtered,10)
in
   Result

 

Unfortunately, i receive the below error:

 

Expression.Error: We cannot convert the value "each [PI_Id] = 2 or ..." to type Function.
Details:
Value=each [PI_Id] = 2 or [PI_Id] = 3 or [PI_Id] = 1
Type=[Type]

 

If i hardcode the condition like below, it works just fine.

let
   filter_indicator = () =>
   let
      output = each [PI_Id] = 2 or [PI_Id] = 3
   in
      output,

      Filtered = Table.SelectRows([Custom2], filter_indicator()),
      Result = Table.FirstN(Filtered,10)
in
    Result

 

Any help is greatly appreciated.

 

Regards

1 ACCEPTED SOLUTION
jbwtp
Memorable Member
Memorable Member

Hi @brassy27,

 

you were almost there. All you needed was Expression.Evaluate overlay:

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlTSUUpNTM5QiPZMibU1VMgvArMUbBWMlGJ1opWMkOVjSg0MjJON4IrA/FQFU7BKY6BKMMMMxjAHM2IB", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Id = _t, Filter = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Id", Int64.Type}, {"Filter", type text}}),
    
    #"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each Table.SelectRows(#"Changed Type", Expression.Evaluate([Filter])))
in
    #"Added Custom"

 

Cheers,

John

View solution in original post

2 REPLIES 2
jbwtp
Memorable Member
Memorable Member

Hi @brassy27,

 

you were almost there. All you needed was Expression.Evaluate overlay:

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlTSUUpNTM5QiPZMibU1VMgvArMUbBWMlGJ1opWMkOVjSg0MjJON4IrA/FQFU7BKY6BKMMMMxjAHM2IB", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Id = _t, Filter = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Id", Int64.Type}, {"Filter", type text}}),
    
    #"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each Table.SelectRows(#"Changed Type", Expression.Evaluate([Filter])))
in
    #"Added Custom"

 

Cheers,

John

Oh yeah!!!  Thanks a million John, you nailed it!

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

February Power BI Update Carousel

Power BI Monthly Update - February 2026

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.