Don't miss your chance to take the Fabric Data Engineer (DP-600) exam for FREE! Find out how by attending the DP-600 session on April 23rd (pacific time), live or on-demand.
Learn moreNext up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now
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:
Fig. 1
The same table has another basic text column containing:
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:
For 4th row:
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
Solved! Go to Solution.
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
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!
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.
Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.
| User | Count |
|---|---|
| 5 | |
| 3 | |
| 3 | |
| 3 | |
| 2 |