Forum Discussion

hmendezm's avatar
hmendezm
Regular Visitor
1 year ago
Solved

How to pass to report using powerbi-client?

Hi Everybody,

 

I have a report with a parameter(numeric range) that I try to use to calculate values. I also have a parameter that I create in Transformation Data. I try to receive a value(s) from the embedded report component and use it to make calculations in the tables.   I am using Powerbi-client to render the report in the company web app (Angular app). For instance, the table has 3 columns productid, name, and amount. I need to pass the percentage of discount (parameter). Based on this parameter, I need to calculate the discount applied to the product amount and show this info in the report.  Also, the report is accessed by many users, and the percentage is different, so the parameter must be specific to the report instance.  Does someone have ideas on how I can update parameters for a specific report instance or other solutions?

 

best

hmendezm

  • Hi hmendezm ,

    Filters work well for selecting data, but they don’t directly impact calculations in a report. Since Power BI parameters can’t be dynamically updated per user in an embedded scenario, a different approach is needed.

    A better solution is to use a measure in Power BI to dynamically apply the discount percentage. Here’s how you can do it:

    • Create a table in Power BI with possible discount percentages.

    • Use a measure to calculate the discount based on the selected percentage.

    • Pass the discount percentage from the web application as a filter when embedding the report, ensuring each user sees their specific discount without requiring a dataset refresh.

    This approach allows discount calculations to update dynamically within Power BI, without modifying the dataset or triggering a full refresh. Let me know if you’d like more details on setting it up!

    If this post was helpful, please give us Kudos and consider marking Accept as solution to assist other members in finding it more easily.

     

6 Replies

  • v-menakakota's avatar
    v-menakakota
    Community Support

    Hi hmendezm ,

    Thank you for reaching out to us on the Microsoft Fabric Community Forum.

    To dynamically pass a discount percentage to an embedded Power BI report in an Angular application using powerbi-client, it's best to use filters rather than parameters, as Power BI Embedded does not support modifying parameters at runtime.

    Apply a dynamic filter before rendering the report to ensure each user sees their specific discount based on their login details.

    If the discount percentage is defined as a Power Query parameter, you can update it using the Power BI REST API. However, this requires a dataset refresh, making it less suitable for real-time updates.

    To ensure each user only sees their relevant data, apply RLS to restrict access at the dataset level. This enhances security without requiring additional frontend filtering.

    By combining filters for real-time updates, REST API for backend parameter management, and RLS for user-specific data control, you can ensure the report dynamically reflects user-specific discount values while maintaining performance and security.

    If this post was helpful, please give us Kudos and consider marking Accept as solution to assist other members in finding it more easily.

    • hmendezm's avatar
      hmendezm
      Regular Visitor

      Hi v-menakakota

      Thank you very much for taking the time to reply to my question. We use filters in the report, and it works great to filter the data in the report. However,  we need to use the percentage passed from the UI to calculate the percentages in a table.  Is it possible in the transformation data section?

       

      Best

      hmendezm

      • v-menakakota's avatar
        v-menakakota
        Community Support

        Hi hmendezm ,

        Filters work well for selecting data, but they don’t directly impact calculations in a report. Since Power BI parameters can’t be dynamically updated per user in an embedded scenario, a different approach is needed.

        A better solution is to use a measure in Power BI to dynamically apply the discount percentage. Here’s how you can do it:

        • Create a table in Power BI with possible discount percentages.

        • Use a measure to calculate the discount based on the selected percentage.

        • Pass the discount percentage from the web application as a filter when embedding the report, ensuring each user sees their specific discount without requiring a dataset refresh.

        This approach allows discount calculations to update dynamically within Power BI, without modifying the dataset or triggering a full refresh. Let me know if you’d like more details on setting it up!

        If this post was helpful, please give us Kudos and consider marking Accept as solution to assist other members in finding it more easily.