Forum Discussion

pearl's avatar
pearl
Frequent Visitor
2 years ago
Solved

Dynamic parameter values in Odataservice URL in Power BI

Dear Experts, 

I need your help with the following scenario. 

I am fetching data from SAP S4 HANA CDS Views into Power BI through Odataservice. The Odataservice URL has the parameter values hardcoded, which is why my report shows data only for that particular value. To be more specific, company code is the parameter which is getting data only for one value say 1000. I want to make this dynamic and allow users to enter whatever Company code value they want and the report should be able to display it. Can someone please help me with the issue.

You help is much appreciated.

 

Thank you in advance.

 

  • Anonymous's avatar
    Anonymous
    2 years ago

    Hi pearl 

    If your connect mode is direct query, you can create a paramater in power query, then set the paramater with slicer, you can refer to the following link.

    Dynamic M query parameters in Power BI Desktop - Power BI | Microsoft Learn

    The following sample cannot allow the user to input the parameter, if you want to edit the paramater to change the filter, you can only do it in power query or edit it in data source setting when the report is publised to Service, you can refer to the following link.

    Edit parameter settings in the Power BI service - Power BI | Microsoft Learn

    Sample data 

     

    Step1 Create a paramater in power query

     

    Step 2:

    Put the paramater to the code

    let
      para="?$filter=EmployeeID eq "&Text.From(Parameter1),
      Source = OData.Feed("https://services.odata.org/V3/Northwind/Northwind.svc/Employees"&para, null, [Implementation="2.0"])
    in
        Source

     

    Best Regards!

    Yolo Zhu

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

     

2 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi pearl 

    If your connect mode is direct query, you can create a paramater in power query, then set the paramater with slicer, you can refer to the following link.

    Dynamic M query parameters in Power BI Desktop - Power BI | Microsoft Learn

    The following sample cannot allow the user to input the parameter, if you want to edit the paramater to change the filter, you can only do it in power query or edit it in data source setting when the report is publised to Service, you can refer to the following link.

    Edit parameter settings in the Power BI service - Power BI | Microsoft Learn

    Sample data 

     

    Step1 Create a paramater in power query

     

    Step 2:

    Put the paramater to the code

    let
      para="?$filter=EmployeeID eq "&Text.From(Parameter1),
      Source = OData.Feed("https://services.odata.org/V3/Northwind/Northwind.svc/Employees"&para, null, [Implementation="2.0"])
    in
        Source

     

    Best Regards!

    Yolo Zhu

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

     

    • pearl's avatar
      pearl
      Frequent Visitor

      Hello Yolo Zhu,

       

      Thank you for the response. That worked actually. 

       

      Best Regards,

      Pearl