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

Try your skills in the Power BI Dataviz World Championship! Round one ends June 26. Join now

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
Fabric Data Days is here Carousel

Fabric Data Days 2026

Don't miss out on Data Days, June 15 through August 7. Learn Fabric, Power BI, SQL, AI and more.

May Power BI Update Carousel

Power BI Monthly Update - May 2026

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

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.