<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: The mystery behind PowerBI Tile dataset changing in Developer</title>
    <link>https://community.fabric.microsoft.com/t5/Developer/The-mystery-behind-PowerBI-Tile-dataset-changing/m-p/3168722#M42048</link>
    <description>&lt;P&gt;Thank you so much for your reply, Mr. Hersch.&lt;/P&gt;&lt;P&gt;I have used dynamic binding for when I am embedding an entire report in another place in the app.&amp;nbsp;&lt;BR /&gt;However, would this approach stay true for tiles as well ?&lt;/P&gt;</description>
    <pubDate>Mon, 03 Apr 2023 08:00:58 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2023-04-03T08:00:58Z</dc:date>
    <item>
      <title>The mystery behind PowerBI Tile dataset changing</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/The-mystery-behind-PowerBI-Tile-dataset-changing/m-p/3130204#M41713</link>
      <description>&lt;P&gt;The&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;.NET PowerBI SDK&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;offers the&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;Tile&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;class in the Microsoft.PowerBI.Api.Models namespace.&lt;/P&gt;&lt;P&gt;This Tile class, interestingly enough, has a&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;DatasetId&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;public property that has&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;both a public getter and a public setter&lt;/STRONG&gt;.&lt;/P&gt;&lt;P&gt;I have the following method below, which aims to ultimately return a custom made object of type&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;PowerBITileEmbedInfo&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;containing all rendering configuration values needed to the&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;PowerBI JS SDK&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;on the frontend side:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;public&lt;/SPAN&gt; &lt;SPAN class=""&gt;async&lt;/SPAN&gt; Task&amp;lt;PowerBITileEmbedInfo&amp;gt; &lt;SPAN class=""&gt;GetDefaultTileEmbedInfo&lt;/SPAN&gt;()&lt;/SPAN&gt;
        {
                var currentUserId = 1;&lt;BR /&gt;
                &lt;SPAN class=""&gt;// Get a list of dashboards.&lt;/SPAN&gt;
                &lt;SPAN class=""&gt;var&lt;/SPAN&gt; dashboards = &lt;SPAN class=""&gt;await&lt;/SPAN&gt; m_PowerBIClient.Dashboards.GetDashboardsInGroupAsync(m_ReportsWorkspaceId);

                &lt;SPAN class=""&gt;// Get the first report in the workspace.&lt;/SPAN&gt;
                &lt;SPAN class=""&gt;var&lt;/SPAN&gt; dashboard = dashboards.Value.FirstOrDefault();

                &lt;SPAN class=""&gt;if&lt;/SPAN&gt; (dashboard == &lt;SPAN class=""&gt;null&lt;/SPAN&gt;)
                {
                    &lt;SPAN class=""&gt;throw&lt;/SPAN&gt; &lt;SPAN class=""&gt;new&lt;/SPAN&gt; NullReferenceException(&lt;SPAN class=""&gt;"Workspace has no dashboards"&lt;/SPAN&gt;);
                }

                &lt;SPAN class=""&gt;var&lt;/SPAN&gt; tiles = &lt;SPAN class=""&gt;await&lt;/SPAN&gt; m_PowerBIClient.Dashboards.GetTilesInGroupAsync(m_ReportsWorkspaceId, dashboard.Id);

                &lt;SPAN class=""&gt;// Get the first tile in the workspace.&lt;/SPAN&gt;
                &lt;SPAN class=""&gt;var&lt;/SPAN&gt; tile = tiles.Value.FirstOrDefault();

                &lt;SPAN class=""&gt;string&lt;/SPAN&gt; datasetId = tile.DatasetId;

                &lt;SPAN class=""&gt;// Generate Embed Token for a tile.&lt;/SPAN&gt;
                &lt;SPAN class=""&gt;var&lt;/SPAN&gt; effectiveIdentities = &lt;SPAN class=""&gt;new&lt;/SPAN&gt; List&amp;lt;EffectiveIdentity&amp;gt;();
                &lt;SPAN class=""&gt;var&lt;/SPAN&gt; effectiveIdentity = &lt;SPAN class=""&gt;new&lt;/SPAN&gt; EffectiveIdentity()
                {
                    Username = currentUserId.ToString(),
                    Roles = &lt;SPAN class=""&gt;new&lt;/SPAN&gt; List&amp;lt;&lt;SPAN class=""&gt;string&lt;/SPAN&gt;&amp;gt;() { &lt;SPAN class=""&gt;"Reader"&lt;/SPAN&gt; },
                    Datasets = &lt;SPAN class=""&gt;new&lt;/SPAN&gt; List&amp;lt;&lt;SPAN class=""&gt;string&lt;/SPAN&gt;&amp;gt;() { datasetId }
                };

                effectiveIdentities.Add(effectiveIdentity);

                &lt;SPAN class=""&gt;var&lt;/SPAN&gt; generateTokenRequestParameters = &lt;SPAN class=""&gt;new&lt;/SPAN&gt; GenerateTokenRequest(accessLevel: &lt;SPAN class=""&gt;"view"&lt;/SPAN&gt;, identities: effectiveIdentities);
                &lt;SPAN class=""&gt;var&lt;/SPAN&gt; tokenResponse = &lt;SPAN class=""&gt;await&lt;/SPAN&gt; m_PowerBIClient.Tiles.GenerateTokenInGroupAsync(m_ReportsWorkspaceId, dashboard.Id, tile.Id, generateTokenRequestParameters);

                &lt;SPAN class=""&gt;if&lt;/SPAN&gt; (tokenResponse == &lt;SPAN class=""&gt;null&lt;/SPAN&gt;)
                {
                    &lt;SPAN class=""&gt;throw&lt;/SPAN&gt; &lt;SPAN class=""&gt;new&lt;/SPAN&gt; NullReferenceException(&lt;SPAN class=""&gt;"Failed to generate embed token"&lt;/SPAN&gt;);
                }


                &lt;SPAN class=""&gt;// Generate Embed Configuration.&lt;/SPAN&gt;
                &lt;SPAN class=""&gt;var&lt;/SPAN&gt; tileEmbedConfig = &lt;SPAN class=""&gt;new&lt;/SPAN&gt; PowerBITileEmbedInfo()
                {
                    AccessToken = tokenResponse.Token,
                    EmbedUrl = tile.EmbedUrl,
                    TileId = tile.Id.ToString(),
                    DashboardId = dashboard.Id.ToString()
                };

                &lt;SPAN class=""&gt;return&lt;/SPAN&gt; tileEmbedConfig;
           

        }&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am basically assigning the DataSetId property that comes directly from the tile object to the datasetId variable that I subsequently use for my EffectiveIdentity (for RLS).&lt;/P&gt;&lt;P&gt;From my understanding, a&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;tile&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;is a part of a&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;report&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;which has a Dataset behind it.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;My goal is to be able to change the dataset and thus have the tile's data reflect this accordingly&lt;/STRONG&gt;. I would require it since the app I am developing is multi tenant and I would like to have the tile be relevant to a dataset linked with each tenant.&lt;/P&gt;&lt;P&gt;The PowerBI documentation available online is often blurry in terms of making it crisp clear when should one use V1 for generating the embed token, or when to use V2, or how to approach this.&lt;/P&gt;&lt;P&gt;Is it even possible to programmatically change the dataset behind a tile and have the UI data reflect this well enough ?&lt;/P&gt;&lt;P&gt;Do I need to first change the dataset behind the report out of which I'm getting the tile, and then attempt to get the tile ? If so, how can I correctly generate the embed token ?&lt;/P&gt;&lt;P&gt;P.S. I would speculate rebinding is not the way to go.&lt;/P&gt;</description>
      <pubDate>Tue, 14 Mar 2023 09:11:33 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/The-mystery-behind-PowerBI-Tile-dataset-changing/m-p/3130204#M41713</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2023-03-14T09:11:33Z</dc:date>
    </item>
    <item>
      <title>Re: The mystery behind PowerBI Tile dataset changing</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/The-mystery-behind-PowerBI-Tile-dataset-changing/m-p/3130252#M41714</link>
      <description>&lt;P&gt;Power BI reports can be dynamically bound to a dataset when embedding the report.&lt;/P&gt;&lt;P&gt;Did you see the documentation here:&lt;/P&gt;&lt;P&gt;&lt;A href="https://learn.microsoft.com/en-us/power-bi/developer/embedded/embed-dynamic-binding" target="_blank"&gt;Connect a Power BI report to a dataset using dynamic binding - Power BI | Microsoft Learn&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://learn.microsoft.com/en-us/javascript/api/overview/powerbi/bind-report-datasets" target="_blank"&gt;Bind datasets dynamically to a Power BI embedded report in Power BI embedded analytics | Microsoft Learn&lt;/A&gt;&lt;/P&gt;&lt;P&gt;I believe you should always use V2 embed tokens, to enjoy dynamic binding option as well as other advanced options which are only supported by V2 tokens.&lt;/P&gt;</description>
      <pubDate>Tue, 14 Mar 2023 09:09:03 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/The-mystery-behind-PowerBI-Tile-dataset-changing/m-p/3130252#M41714</guid>
      <dc:creator>AmosHersch</dc:creator>
      <dc:date>2023-03-14T09:09:03Z</dc:date>
    </item>
    <item>
      <title>Re: The mystery behind PowerBI Tile dataset changing</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/The-mystery-behind-PowerBI-Tile-dataset-changing/m-p/3168722#M42048</link>
      <description>&lt;P&gt;Thank you so much for your reply, Mr. Hersch.&lt;/P&gt;&lt;P&gt;I have used dynamic binding for when I am embedding an entire report in another place in the app.&amp;nbsp;&lt;BR /&gt;However, would this approach stay true for tiles as well ?&lt;/P&gt;</description>
      <pubDate>Mon, 03 Apr 2023 08:00:58 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/The-mystery-behind-PowerBI-Tile-dataset-changing/m-p/3168722#M42048</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2023-04-03T08:00:58Z</dc:date>
    </item>
  </channel>
</rss>

