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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! 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
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Top Solution Authors