<?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: SelectAll is not firing dataSelectedEvent in first instance in Developer</title>
    <link>https://community.fabric.microsoft.com/t5/Developer/SelectAll-is-not-firing-dataSelectedEvent-in-first-instance/m-p/2096271#M32017</link>
    <description>&lt;P&gt;I have an example of it here, it is not necessarily the "Select All", on a multiselect and you untick elements it does not fire.&lt;/P&gt;&lt;P&gt;Here is a code example, here I am setting the slicer dynamically to "Abbas MA-01" with SetSlicerState.&lt;/P&gt;&lt;P&gt;If i was to untick "Abbas MA-01" so everything was considered, the dataSelected event does not fire.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;let loadedResolve, reportLoaded = new Promise((res, rej) =&amp;gt; { loadedResolve = res; });
let renderedResolve, reportRendered = new Promise((res, rej) =&amp;gt; { renderedResolve = res; });

// Get models. models contains enums that can be used.
models = window['powerbi-client'].models;

// Embed a Power BI report in the given HTML element with the given configurations
// Read more about how to embed a Power BI report in your application here: https://go.microsoft.com/fwlink/?linkid=2153590
function embedPowerBIReport() {
    /*-----------------------------------------------------------------------------------+
    |    Don't change these values here: access token, embed URL and report ID.          | 
    |    To make changes to these values:                                                | 
    |    1. Save any other code changes to a text editor, as these will be lost.         |
    |    2. Select 'Start over' from the ribbon.                                         |
    |    3. Select a report or use an embed token.                                       |
    +-----------------------------------------------------------------------------------*/
    // Read embed application token
    let accessToken = EMBED_ACCESS_TOKEN;

    // Read embed URL
    let embedUrl = EMBED_URL;

    // Read report Id
    let embedReportId = REPORT_ID;

    // Read embed type from radio
    let tokenType = TOKEN_TYPE;

    // We give All permissions to demonstrate switching between View and Edit mode and saving report.
    let permissions = models.Permissions.All;

    // Create the embed configuration object for the report
    // For more information see https://go.microsoft.com/fwlink/?linkid=2153590
    let config = {
        type: 'report',
        tokenType: tokenType == '0' ? models.TokenType.Aad : models.TokenType.Embed,
        accessToken: accessToken,
        embedUrl: embedUrl,
        id: embedReportId,
        permissions: permissions,
        settings: {
            panes: {
                filters: {
                    visible: true
                },
                pageNavigation: {
                    visible: true
                }
            }
        }
    };

    // Get a reference to the embedded report HTML element
    let embedContainer = $('#embedContainer')[0];

    // Embed the report and display it within the div container.
    report = powerbi.embed(embedContainer, config);

    // report.off removes all event handlers for a specific event
    report.off("loaded");

    // report.on will add an event handler
    report.on("loaded", function () {
        loadedResolve();
        report.off("loaded");
    });

    // report.off removes all event handlers for a specific event
    report.off("error");

    report.on("error", function (event) {
        console.log(event.detail);
    });

    // report.off removes all event handlers for a specific event
    report.off("rendered");

    // report.on will add an event handler
    report.on("rendered", function () {
        renderedResolve();
        report.off("rendered");
    });
}

embedPowerBIReport();
await reportLoaded;

// Insert here the code you want to run after the report is loaded
// report.off removes all event handlers for a specific event
report.off("dataSelected");

// report.on will add an event listener.
report.on("dataSelected", function (event) {
    let data = event.detail;
    console.log("Event - dataSelected:\n", data);
});



// Create the filter object. For more information see https://go.microsoft.com/fwlink/?linkid=2153364
const filter = {
    $schema: "http://powerbi.com/product/schema#basic",
    target: {
        table: "Product",
        column: "Product"
    },
    filterType: models.FilterType.BasicFilter,
    operator: "In",
    values: ["Abbas MA-01"],
    requireSingleSelection: true
};

// Retrieve the page collection and get the visuals for the active page.
try {
    const pages = await report.getPages();

    // Retrieve the active page.
    let page = pages.filter(function (page) {
        return page.isActive;
    })[0];

    const visuals = await page.getVisuals();

    // Retrieve the target visual.
    let slicer = visuals.filter(function (visual) {
        return visual.type === "slicer" &amp;amp;&amp;amp; visual.name === "93f1e286b34bd2112237";
    })[0];

    // Set the slicer state which contains the slicer filters.
    await slicer.setSlicerState({ filters: [filter] });
    console.log("slicer was set.");
}
catch (errors) {
    console.log(errors);
}


await reportRendered;

// Insert here the code you want to run after the report is rendered
&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 24 Sep 2021 07:46:12 GMT</pubDate>
    <dc:creator>Nojustice</dc:creator>
    <dc:date>2021-09-24T07:46:12Z</dc:date>
    <item>
      <title>SelectAll is not firing dataSelectedEvent in first instance</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/SelectAll-is-not-firing-dataSelectedEvent-in-first-instance/m-p/2075654#M31745</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;We have a report with a multi-select slicer which has the "Select All" attribute added,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When the report is rendered the slicer value is of a set value "Value1", if we change that value to "Select All", the dataSelected Event is not fired.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It seems like you have to select another options first and then "Select All" for it to eventually decide that the event should be fired&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Unfortunately I cannot provide an example of this as the sample report on the sandbox does not have the select all option on the multi-select slicers&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can this be fixed?&lt;/P&gt;</description>
      <pubDate>Tue, 14 Sep 2021 14:48:15 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/SelectAll-is-not-firing-dataSelectedEvent-in-first-instance/m-p/2075654#M31745</guid>
      <dc:creator>Nojustice</dc:creator>
      <dc:date>2021-09-14T14:48:15Z</dc:date>
    </item>
    <item>
      <title>Re: SelectAll is not firing dataSelectedEvent in first instance</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/SelectAll-is-not-firing-dataSelectedEvent-in-first-instance/m-p/2082344#M31843</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="281951" data-lia-user-login="Nojustice" class="lia-mention lia-mention-user"&gt;Nojustice&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;Could you please provide a code snippet or some screenshots of the &lt;SPAN&gt;dataSelected Event&lt;/SPAN&gt;? Does any other slicer not trigger the dataSelected Event when the slicer option is first switched to Select All?&lt;/P&gt;
&lt;P&gt;&lt;A href="https://community.powerbi.com/t5/Issues/Power-BI-Embedded-dataSelected-event-not-triggered/idi-p/876349" target="_self"&gt;&lt;STRONG&gt;Power BI Embedded dataSelected event not triggered&lt;/STRONG&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://community.powerbi.com/t5/Developer/dataSelected-on-table/m-p/111347" target="_self"&gt;&lt;STRONG&gt;&lt;SPAN&gt;dataSelected&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;Best Regards&lt;/P&gt;</description>
      <pubDate>Fri, 17 Sep 2021 09:24:48 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/SelectAll-is-not-firing-dataSelectedEvent-in-first-instance/m-p/2082344#M31843</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-09-17T09:24:48Z</dc:date>
    </item>
    <item>
      <title>Re: SelectAll is not firing dataSelectedEvent in first instance</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/SelectAll-is-not-firing-dataSelectedEvent-in-first-instance/m-p/2096271#M32017</link>
      <description>&lt;P&gt;I have an example of it here, it is not necessarily the "Select All", on a multiselect and you untick elements it does not fire.&lt;/P&gt;&lt;P&gt;Here is a code example, here I am setting the slicer dynamically to "Abbas MA-01" with SetSlicerState.&lt;/P&gt;&lt;P&gt;If i was to untick "Abbas MA-01" so everything was considered, the dataSelected event does not fire.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;let loadedResolve, reportLoaded = new Promise((res, rej) =&amp;gt; { loadedResolve = res; });
let renderedResolve, reportRendered = new Promise((res, rej) =&amp;gt; { renderedResolve = res; });

// Get models. models contains enums that can be used.
models = window['powerbi-client'].models;

// Embed a Power BI report in the given HTML element with the given configurations
// Read more about how to embed a Power BI report in your application here: https://go.microsoft.com/fwlink/?linkid=2153590
function embedPowerBIReport() {
    /*-----------------------------------------------------------------------------------+
    |    Don't change these values here: access token, embed URL and report ID.          | 
    |    To make changes to these values:                                                | 
    |    1. Save any other code changes to a text editor, as these will be lost.         |
    |    2. Select 'Start over' from the ribbon.                                         |
    |    3. Select a report or use an embed token.                                       |
    +-----------------------------------------------------------------------------------*/
    // Read embed application token
    let accessToken = EMBED_ACCESS_TOKEN;

    // Read embed URL
    let embedUrl = EMBED_URL;

    // Read report Id
    let embedReportId = REPORT_ID;

    // Read embed type from radio
    let tokenType = TOKEN_TYPE;

    // We give All permissions to demonstrate switching between View and Edit mode and saving report.
    let permissions = models.Permissions.All;

    // Create the embed configuration object for the report
    // For more information see https://go.microsoft.com/fwlink/?linkid=2153590
    let config = {
        type: 'report',
        tokenType: tokenType == '0' ? models.TokenType.Aad : models.TokenType.Embed,
        accessToken: accessToken,
        embedUrl: embedUrl,
        id: embedReportId,
        permissions: permissions,
        settings: {
            panes: {
                filters: {
                    visible: true
                },
                pageNavigation: {
                    visible: true
                }
            }
        }
    };

    // Get a reference to the embedded report HTML element
    let embedContainer = $('#embedContainer')[0];

    // Embed the report and display it within the div container.
    report = powerbi.embed(embedContainer, config);

    // report.off removes all event handlers for a specific event
    report.off("loaded");

    // report.on will add an event handler
    report.on("loaded", function () {
        loadedResolve();
        report.off("loaded");
    });

    // report.off removes all event handlers for a specific event
    report.off("error");

    report.on("error", function (event) {
        console.log(event.detail);
    });

    // report.off removes all event handlers for a specific event
    report.off("rendered");

    // report.on will add an event handler
    report.on("rendered", function () {
        renderedResolve();
        report.off("rendered");
    });
}

embedPowerBIReport();
await reportLoaded;

// Insert here the code you want to run after the report is loaded
// report.off removes all event handlers for a specific event
report.off("dataSelected");

// report.on will add an event listener.
report.on("dataSelected", function (event) {
    let data = event.detail;
    console.log("Event - dataSelected:\n", data);
});



// Create the filter object. For more information see https://go.microsoft.com/fwlink/?linkid=2153364
const filter = {
    $schema: "http://powerbi.com/product/schema#basic",
    target: {
        table: "Product",
        column: "Product"
    },
    filterType: models.FilterType.BasicFilter,
    operator: "In",
    values: ["Abbas MA-01"],
    requireSingleSelection: true
};

// Retrieve the page collection and get the visuals for the active page.
try {
    const pages = await report.getPages();

    // Retrieve the active page.
    let page = pages.filter(function (page) {
        return page.isActive;
    })[0];

    const visuals = await page.getVisuals();

    // Retrieve the target visual.
    let slicer = visuals.filter(function (visual) {
        return visual.type === "slicer" &amp;amp;&amp;amp; visual.name === "93f1e286b34bd2112237";
    })[0];

    // Set the slicer state which contains the slicer filters.
    await slicer.setSlicerState({ filters: [filter] });
    console.log("slicer was set.");
}
catch (errors) {
    console.log(errors);
}


await reportRendered;

// Insert here the code you want to run after the report is rendered
&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 24 Sep 2021 07:46:12 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/SelectAll-is-not-firing-dataSelectedEvent-in-first-instance/m-p/2096271#M32017</guid>
      <dc:creator>Nojustice</dc:creator>
      <dc:date>2021-09-24T07:46:12Z</dc:date>
    </item>
    <item>
      <title>Re: SelectAll is not firing dataSelectedEvent in first instance</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/SelectAll-is-not-firing-dataSelectedEvent-in-first-instance/m-p/2127319#M32325</link>
      <description>&lt;P&gt;the code snippet has been supplied.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have contacted MS directly and they have classified this issue as a bug and it is being worked on currently.&lt;/P&gt;&lt;P&gt;I will update this post when I have information to share&lt;/P&gt;</description>
      <pubDate>Mon, 11 Oct 2021 12:44:04 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/SelectAll-is-not-firing-dataSelectedEvent-in-first-instance/m-p/2127319#M32325</guid>
      <dc:creator>Nojustice</dc:creator>
      <dc:date>2021-10-11T12:44:04Z</dc:date>
    </item>
  </channel>
</rss>

