Forum Discussion

marcio_fornari's avatar
marcio_fornari
Icon for Resolver I rankResolver I
2 days ago

Dax - Execute Queries/RLS

It's possible execute dax query against dataset with RLS to Power BI Embedded?

https://learn.microsoft.com/en-us/rest/api/power-bi/datasets/execute-queries

To Power BI Embedded my users not need power bi account, this example works only with power bi account.

{ "queries":  [{"query": "EVALUATE VALUES(MyTable)" } ],    "serializerSettings": {"includeNulls": true },   "impersonatedUserName": "[email protected]" }

i would like send the Rule and the username together with dax query.

2 Replies

  • Yes — the Execute Queries API supports this directly, and it's the standard way to get RLS-aware DAX results for embedded users who don't have a Power BI account.

    The request body takes an 'identities' array alongside your 'queries' array. Each identity object carries a 'username' (any string identifying the end user — it doesn't need to be a real UPN) and a 'roles' array naming the RLS role(s) from your model to apply. That's the same effective-identity mechanism Embedded uses for embed tokens, just passed to Execute Queries instead.

    So your body becomes something like { "queries": [...], "identities": [ { "username": "someuser", "roles": ["YourRLSRoleName"] } ] }. The DAX query then runs as if that user were logged in and subject to that role's filter.

    One thing worth double-checking: if your RLS rule expressions read USERNAME() vs CUSTOMDATA(), make sure you're populating the matching field on the identity object — username feeds USERNAME()/USERPRINCIPALNAME(), and there's a separate 'customData' property on the identity if your rules use CUSTOMDATA() instead.

  • v-sathmakuri's avatar
    v-sathmakuri
    Icon for Community Support rankCommunity Support

    Hi marcio_fornari​ ,

    Thank you for reaching out to fabric community.

    For Power BI Embedded (App owns data), the recommended approach is to generate the embed token with an EffectiveIdentity, passing the user's username and the RLS role:

    { "username": "user123", "roles": ["MyRLSRole"], "datasets": ["dataset-id"] }

    The embedded user doesn't need a Power BI account. Power BI will apply the RLS role when querying the semantic model.

    However, you can't pass the RLS role + username to the Execute Queries API using a service principal in the same way. impersonatedUserName has separate authentication/permission requirements and isn't a replacement for Embedded EffectiveIdentity.

    Using standard cloud based row-level security with embedded content in Power BI embedded analytics - Power BI | Microsoft Learn

    Thanks!!