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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
t4r05
New Member

Combine inline function in query

Hi,
I'm trying to create a custom function and use it in a query. I'm able to create a function in PBI Desktop and then use it in query, but i need to comibne it in a query so instead:
let Source = OData.Feed("https://endpoint/odata"),
Bills_table = Source{[Name="Bills",Signature="table"]}[Data],
Result = Table.AddColumn(Bills_table, "MapValue", each Map(_[AmountBilled]))
in
Result
 
where Map is my function, I want to combine this with query. Is this achievable ?
 
 
let Map = (val as number) => if val > 10 then "a" else "b" <-- some functino defined before rest of query
let Source = OData.Feed("https://endpoint/odata"),
Bills_table = Source{[Name="Bills",Signature="table"]}[Data],
Result = Table.AddColumn(Bills_table, "MapValue", each Map(_[AmountBilled]))
in
Result
1 ACCEPTED SOLUTION
v-jiascu-msft
Microsoft Employee
Microsoft Employee

Hi @t4r05,

 

You just need to remove the second "let". 

let 
    Map = (val as number) => if val >= 10 then "a" else "b", // -- some functino defined before rest of query
let Source = OData.Feed("https://endpoint/odata"),
    Bills_table = Source{[Name="Bills",Signature="table"]}[Data],
    Result = Table.AddColumn(Bills_table, "MapValue", each Map(_[AmountBilled]))
in
    Result

Best Regards,

Dale

Community Support Team _ Dale
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
v-jiascu-msft
Microsoft Employee
Microsoft Employee

Hi @t4r05,

 

Could you please mark the proper answer as a solution?

 

Best Regards,
Dale

Community Support Team _ Dale
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
v-jiascu-msft
Microsoft Employee
Microsoft Employee

Hi @t4r05,

 

You just need to remove the second "let". 

let 
    Map = (val as number) => if val >= 10 then "a" else "b", // -- some functino defined before rest of query
let Source = OData.Feed("https://endpoint/odata"),
    Bills_table = Source{[Name="Bills",Signature="table"]}[Data],
    Result = Table.AddColumn(Bills_table, "MapValue", each Map(_[AmountBilled]))
in
    Result

Best Regards,

Dale

Community Support Team _ Dale
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
zoloturu
Memorable Member
Memorable Member

Hi @t4r05,

 

Modify the name of the function and code as below on the screenshot and try again:

 

mapmap

let 
    Source = (val as number) => if val > 10 then "a" else "b" 
in
    Source

Regards,

Ruslan

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.