Power BI Filter data based on user

Shreyas Rastogi 225 Reputation points
2023-06-14T20:43:19.36+00:00

I have a requirement to filter data in power BI based on user .

So when a user logs in Power BI desktop

  1. Can we trigger Power BI query on user login to call Microsoft Graph API to get user attributes
  2. once we have this data , we filter data based on the attributes .

So in short , Can i trigger a graph api call on power BI login and filter data based on response .

Thanks,

Shreyas

Microsoft Security | Microsoft Graph
0 comments No comments
{count} votes

3 answers

Sort by: Most helpful
  1. Khaled Elsayed Mohamed 1,335 Reputation points
    2023-07-06T09:51:49.35+00:00

    Hi SR

    As of my knowledge cutoff in September 2021, Power BI Desktop does not provide a built-in capability to directly trigger a Graph API call upon user login. Power BI is primarily focused on data visualization and analysis rather than user authentication and authorization.

    However, you can achieve the desired functionality by leveraging other tools or platforms in conjunction with Power BI. Here's a high-level approach:

    1. User Authentication: Implement user authentication using a separate platform or technology such as Azure Active Directory (AAD), OAuth, or custom authentication. This will provide a secure and authenticated login process for your users.
    2. Graph API Integration: Once the user is authenticated, you can integrate with the Microsoft Graph API within your application or backend. Use the appropriate authentication flow (e.g., OAuth 2.0) to obtain an access token to make authorized requests to the Graph API.
    3. Retrieve User Attributes: Make a request to the Graph API to retrieve the required user attributes for the logged-in user. You can fetch information such as user profile, group membership, or other relevant attributes that you want to use for data filtering.
    4. Data Filtering in Power BI: With the user attributes obtained from the Graph API, you can apply data filtering in Power BI to display only the relevant data for the logged-in user. This can be achieved by modifying your Power BI queries or applying row-level security (RLS) to restrict access to specific data based on user attributes.
    5. Publish Power BI Reports/Dashboards: Once the data filtering is implemented, publish the Power BI reports or dashboards to the appropriate Power BI service (e.g., Power BI Online or Power BI Report Server). Users can then access the reports with the applied data filtering based on their attributes.

    It's worth mentioning that Power BI Premium and Power BI Embedded offer more advanced capabilities for row-level security, dynamic data filtering, and user attribute-based filtering. These features provide more fine-grained control over data access based on user attributes.

    Keep in mind that the Power BI platform evolves over time, and there may be updates or new features that address user authentication and data filtering requirements more directly. I recommend referring to the official Power BI documentation and staying up-to-date with the latest features and enhancements.

    https://learn.microsoft.com/en-us/power-bi/


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    0 comments No comments

  2. Sanmeet Gurudatta 0 Reputation points
    2023-10-22T11:27:34.3233333+00:00

    hello ,

    you are thinking it wrong way:

    by default when a report is shared with a user - they have to login using credentials. so firing graph API doe not add much value.

    Alternatively , you can " Manage Roles" in the report you are trying to filter data by user

    1. In power BI desktop, go to manage roles and define filter criterion

    manageroles - row level security

    1. you have to define roles, and associated permissions for the roles using dax FILTERS
    2. In power Bi service you assing "roles" to users; not the users inherit the permissions defined for the role for the report.

    take a look at this video and you will understand ; please get back if you have questions / accept the answer

    video Link : https://www.youtube.com/watch?v=MxU_FYSSnYU

    0 comments No comments

  3. Tarun Preet Singh Maini 0 Reputation points
    2024-12-15T17:01:27.4233333+00:00

    Depending upon the exact request and filter requirements we can implement filters or apply RLS (Row Level Security)

    for instance, we can extract the user accessing the report from userprincipalname() and username() functions and join with your data if it contains names or emails and implement static RLS

    you can also create measures using the mentioned functions to visual level filters if the requirement is not to filter the entire data

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.