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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
tobiaslatta
Frequent Visitor

Calling API based on filtered Data

Hey guys,

I am new to PBI and hope that I did not miss an existing thread about the following topic.

Our situation: We have a table with let's say username and ages. I want to filter this table on a certain age. With the filtered list of users, an API shall be dynamically called. The API will return a single numeric value for the list of users. Besides, the API won't officially be supported by PBI. Right now the API is called via an empty query and a Web.Contents statement like this:

 

let
    url = "http://127.0.0.1:8080/reviews/",
    headers = [#"Content-Type" = "application/json"],
    postData = Json.FromValue([review_ts = _review_ts, name = _name]),
    response = Web.Contents(
        url,
        [
            Headers = headers,
            Content = postData
        ]
    ),
    jsonResponse = Json.Document(response)
in
    jsonResponse

 

My problem is that I can not figure out how to pass the filtered table (or list) to _name so it gets used in the query. We need our end-users to filter the table from the Dashboard. The problem with this is that if I understood it correctly, I can not make use of Dynamic M queries to , because this is no Direct Query.

Question: How would you solve this issue? Is there a way to convert it to a Direct Query? I also tried realizing this with a Python script but in order to formulate the POST request, I need a Python package that is difficult to enable on the PBI service (security reasons). Oh yeah, I almost forgot: In the end this report shall run on the PBI service

 

I would appreciate your helpful guidance 🙂

2 REPLIES 2
v-xiaotang
Community Support
Community Support

Hi @tobiaslatta 

I'm afraid of it's not possible. For Power BI Desktop, you can use dax expression to get the filterd table (or list), but it cannot be passed from visual to M code in Power Query. FYI: Slicer Value as a parameter to stored procedure

 

 

Best Regards,

Community Support Team _Tang

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

Well that does not resolve our problem. Is there maybe another way via Power Apps or Power Automate? Or maybe a custom connector?

We are really clueless. It would be real pain point if PowerBI was not able to access APIs dynamically...

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.