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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
Gabry
Super User
Super User

Help needed, including '$' prefix in OData v2 parameters with Power Query

Hello everyone,

I'm trying to connect to a SAP OData v2 service using Power Query in Power BI. I'm accessing an endpoint that requires query parameters with the '$' prefix, as mandated by OData v2.

Here’s what I tried:

 

baseURL = "<SAP OData service URL>",
   
    queryOptions = [
        #"$filter" = "CreationDate ge datetime'" & RangeStartString & "'",
        #"$expand" = "to_....",
        #"$select" = "M...,date,to_..../M....,...",
        #"$top" = "10"
    ]

 

But I got the following error:


Expression.Error: OData.Feed custom query options cannot start with '$'.

If I omit the $ prefix and use this instead:

 

queryOptions = [

        filter = "CreationDate ge datetime'" & RangeStartString & "'",
        expand = "to_....",
        select = "....."

 

 

…the parameters are ignored entirely.

So, how can I include the $ prefix in the query parameters? Is there a workaround or a different approach to make this work? Anyone have any suggestions?

Thanks in advance! 😊

6 REPLIES 6
v-cgao-msft
Community Support
Community Support

Hi @Gabry ,

 

Please refer to Chris Webb's blog:

Using OData.Feed and the Query option to avoid the dynamic data sources error in Power BI

Query options overview - OData | Microsoft Learn

Hope these help.

 

Best Regards,
Gao

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly --  How to provide sample data in the Power BI Forum

Hello @v-cgao-msft ,

Thank you for your response. I came across Chris’s article yesterday and gave that approach a try, but unfortunately, it didn’t work for me either.

It seems that parameters containing "@" are not being passed correctly.

This is the code

let
     baseURL = "http://................?$top=@ttttt",
    
  
    Source = OData.Feed(
        baseURL,
        null,
        [
            Implementation = "2.0",
            Query = [              
                #"@ttttt" = "10"
            ]
        ]
    )
   
in
Source

then i get this error

Gabry_0-1732618426199.png



Can you really pass parameters with @ inside brackets?

Hi @Gabry ,

 

Yes, I tested it using the source in the blog.

let
  Source = OData.Feed(
    "https://services.odata.org/TripPinRESTierService/People?$filter=FirstName eq @fn and LastName eq @ln", 
    null, 
    [
      Implementation = "2.0",
      Query = [#"@fn" = "'Marshall'", #"@ln" = "'Garay'"]
    ]
  )
in
  Source

vcgaomsft_1-1732687725198.png

I seem to be returning a similar error here after removing "‘", try adding "‘".

vcgaomsft_2-1732687968894.png

Best Regards,
Gao

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly --  How to provide sample data in the Power BI Forum

Thank you @v-cgao-msft  for following up!

I’ve tried both with and without the single quotes, but nothing changes — I still get the same error.

I also tested using the URL https://services.odata.org/, and it works fine with this one.

However, it doesn’t work with the SAP OData service. Do you think there’s any other workaround?

It’s frustrating that I have to rely on the web call. With odata would be much better, can't understand why I can't pass the parameters

PhilipTreacy
Super User
Super User

@Gabry 

 

Try Uri.BuildQueryString to assemble the query parameters

 

Uri.BuildQueryString - PowerQuery M | Microsoft Learn

 

Regards

 

Phil

 



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


Hello @PhilipTreacy ,

thanks for the suggestion. I tried but then when published to the service can't be refreshed because of dynamic data source error.
Code was like this:

    baseURL = "http:......",
    
    
    queryParameters = [
        #"$filter" = "C....",
        #"$expand" = "to_M.....",
        #"$select" ="M......e",
        #"$top" = "10"
    ],
    
    queryString = Uri.BuildQueryString(queryParameters),
    
    fullURL = baseURL & "?" & queryString,
    
    Source = OData.Feed(fullURL, null),

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.

Top Solution Authors