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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
smpa01
Super User
Super User

Parametrize columns

I am having issue to pass on columns as parameter for a function callback

 

Non function version

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlTSUTJSitWJBpI6SsZgljGQZaIUGwsA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [colA = _t, colB = _t]),
    ct = Table.TransformColumnTypes(Source,{{"colA", Int64.Type}, {"colB", Int64.Type}}),
    filter = Table.SelectRows(ct, (_)=> (Number.IsEven([colB]) = true))
in
    filter

 

Function

let fn = (tbl as table, filterCol as record) as table =>
    let 
    filter = Table.SelectRows(tbl, (_)=> (Number.IsEven(filterCol) = true))
in
    filter in fn

 

fails on

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlTSUTJSitWJBpI6SsZgljGQZaIUGwsA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [colA = _t, colB = _t]),
    ct = Table.TransformColumnTypes(Source,{{"colA", Int64.Type}, {"colB", Int64.Type}}),
    filter = fx(ct, [colB])
in
    filter

 

Thank you in advance

@AlexisOlson  @dufoq3 

Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs
1 ACCEPTED SOLUTION
AlexisOlson
Super User
Super User

I think this is what you are intending to do.

let
    Source = Table.FromRows({{1,2},{2,3},{3,4}}, type table[colA = Int64.Type, colB = Int64.Type]),
    fx = (tbl as table, filterCol as text) as table =>
        Table.SelectRows(tbl, (_) => Number.IsEven(Record.Field(_, filterCol))),
    filter = fx(Source, "colB")
in
    filter

View solution in original post

3 REPLIES 3
AlexisOlson
Super User
Super User

I think this is what you are intending to do.

let
    Source = Table.FromRows({{1,2},{2,3},{3,4}}, type table[colA = Int64.Type, colB = Int64.Type]),
    fx = (tbl as table, filterCol as text) as table =>
        Table.SelectRows(tbl, (_) => Number.IsEven(Record.Field(_, filterCol))),
    filter = fx(Source, "colB")
in
    filter

Thanks @AlexisOlson. This is awesome.

You saved me a lot of time, chat gpt failed too.

Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs
PwerQueryKees
Super User
Super User

filtercol as record is the problem. try changing to any.

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 2025 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.

Top Kudoed Authors