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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
richanthony
Helper I
Helper I

In Built Report Usage Metrics causing issue when trying embed an RLS enabled report

Hi,

 

**same post as in the service forum as I am not sure where the question sits best. 

 

we are having a challenge with embedded while using RLS, the inbuilt "Report Usage Metrics" dataset seems to be causing an error because RLS is not enable in it. Has any else eperience this issue amd found a resolution?

 

richanthony_0-1669104947702.png

 

 

 

 

 

 

 

3 REPLIES 3
Anonymous
Not applicable

Hi @richanthony ,

 

You may try below code to generate embed token. The report will filter data according to the RLS applied.

public EmbedToken GetEmbedToken(Guid reportId, IList<Guid> datasetIds, [Optional] Guid targetWorkspaceId)
    {
        PowerBIClient pbiClient = this.GetPowerBIClient();

       // Defines the user identity and roles.
        var rlsIdentity = new EffectiveIdentity(
            username: "France",
            roles: new List<string>{ "CountryDynamic" },
            datasets: new List<string>{ datasetId.ToString()}
        );
       
        // Create a request for getting an embed token for the rls identity defined above
        var tokenRequest = new GenerateTokenRequestV2(
            reports: new List<GenerateTokenRequestV2Report>() { new GenerateTokenRequestV2Report(reportId) },
            datasets: datasetIds.Select(datasetId => new GenerateTokenRequestV2Dataset(datasetId.ToString())).ToList(),
            targetWorkspaces: targetWorkspaceId != Guid.Empty ? new List<GenerateTokenRequestV2TargetWorkspace>() { new GenerateTokenRequestV2TargetWorkspace(targetWorkspaceId) } : null,
            identities: new List<EffectiveIdentity> { rlsIdentity }
        );

        // Generate an embed token
        var embedToken = pbiClient.EmbedToken.GenerateToken(tokenRequest);

        return embedToken;
    }

Here I suggest you to refer to this offical blog to learn more details about RLS in Power BI Embed.

For reference: Embed a report with cloud-based RLS

 

Best Regards,
Rico Zhou

 

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

Thanks for taking the time to reply, In this instance it is the "hidden" Report Usage Metrics dataset that does not have RLS configured that is causing the problem. However from what you have said it looks like you can specify the dataset not just the workspace you want to configure so I will give that ago. 

richanthony
Helper I
Helper I

Hi,

 

we are having a challenge with embedded while using RLS, the inbuilt "Report Usage Metrics" dataset seems to be causing an error because RLS is not enable in it. Has any else eperience this issue amd found a resolution?

 

richanthony_0-1669104299369.png

 

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.