<?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: Creating SelectionIds when you have two categories in your DataViewMapping in Developer</title>
    <link>https://community.fabric.microsoft.com/t5/Developer/Creating-SelectionIds-when-you-have-two-categories-in-your/m-p/1661870#M27812</link>
    <description>&lt;P&gt;Hi &lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/231096"&gt;@paul-maessen&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;Yes, I believe so. It should be fairly easy to tell from the resulting SelectionId if it has both categories and indices in the resulting map though, if you wanted to try it out.&lt;/P&gt;
&lt;P&gt;The only thing I might do differently (and this is more of a personal preference and has no net effect on your code) is swap the &lt;FONT face="courier new,courier"&gt;for&lt;/FONT&gt; with a &lt;FONT face="courier new,courier"&gt;forEach&lt;/FONT&gt; and a fat arrow function, e.g.:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="javascript"&gt;categories[0].values.forEach((v, vi) =&amp;gt; {
    const categorySelectionId = this.host.createSelectionIdBuilder()
        .withCategory(categories[0], vi)
        .withCategory(categories[1], vi)
        .createSelectionId();
});&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Cheers,&lt;/P&gt;
&lt;P&gt;Daniel&lt;/P&gt;</description>
    <pubDate>Fri, 12 Feb 2021 03:31:25 GMT</pubDate>
    <dc:creator>dm-p</dc:creator>
    <dc:date>2021-02-12T03:31:25Z</dc:date>
    <item>
      <title>Creating SelectionIds when you have two categories in your DataViewMapping</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Creating-SelectionIds-when-you-have-two-categories-in-your/m-p/1660499#M27793</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I do have a question about the creation of SelectionIds when your DataViewMapping has 2 categories.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The dataRoles and dataViewMapping:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;{
    "dataRoles": [
        {
            "displayName": "Cat 1",
            "name": "cat1",
            "kind": "Grouping"
        },
        {
            "displayName": "Cat 2",
            "name": "cat2",
            "kind": "Grouping"
        },
        {
            "displayName": "Values",
            "name": "values",
            "kind": "Measure"
        }
    ],
    "dataViewMappings": [
        {
            "categorical": {
                "categories": {
                    "for": {
                        "in": "cat1"
                    },
                    "for": {
                        "in": "cat2"
                    }
                },
                "values": {
                    "select": [
                        {
                            "bind": {
                                "to": "values"
                            }
                        }

                }
            }
        }
    ]
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My question is now how I can create the SelectionIds for this situation:&lt;/P&gt;&lt;P&gt;Is the following assumption correct?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;// categories
const categories = dataView.categorical.categories;


// get count of category elements
const categoriesCount = categories[0].values.length;

// iterate all categories to generate selection and create button elements to use selections
for (let categoryIndex = 0; categoryIndex &amp;lt; categoriesCount; categoryIndex++) {

    const categorySelectionId = this.host.createSelectionIdBuilder()
        .withCategory(categories[0], categoryIndex) 
        .withCategory(categories[1], categoryIndex) 
        .createSelectionId();
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Paul&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/397"&gt;@dm-p&lt;/a&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 11 Feb 2021 12:20:18 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Creating-SelectionIds-when-you-have-two-categories-in-your/m-p/1660499#M27793</guid>
      <dc:creator>paul-maessen</dc:creator>
      <dc:date>2021-02-11T12:20:18Z</dc:date>
    </item>
    <item>
      <title>Re: Creating SelectionIds when you have two categories in your DataViewMapping</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Creating-SelectionIds-when-you-have-two-categories-in-your/m-p/1661870#M27812</link>
      <description>&lt;P&gt;Hi &lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/231096"&gt;@paul-maessen&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;Yes, I believe so. It should be fairly easy to tell from the resulting SelectionId if it has both categories and indices in the resulting map though, if you wanted to try it out.&lt;/P&gt;
&lt;P&gt;The only thing I might do differently (and this is more of a personal preference and has no net effect on your code) is swap the &lt;FONT face="courier new,courier"&gt;for&lt;/FONT&gt; with a &lt;FONT face="courier new,courier"&gt;forEach&lt;/FONT&gt; and a fat arrow function, e.g.:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="javascript"&gt;categories[0].values.forEach((v, vi) =&amp;gt; {
    const categorySelectionId = this.host.createSelectionIdBuilder()
        .withCategory(categories[0], vi)
        .withCategory(categories[1], vi)
        .createSelectionId();
});&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Cheers,&lt;/P&gt;
&lt;P&gt;Daniel&lt;/P&gt;</description>
      <pubDate>Fri, 12 Feb 2021 03:31:25 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Creating-SelectionIds-when-you-have-two-categories-in-your/m-p/1661870#M27812</guid>
      <dc:creator>dm-p</dc:creator>
      <dc:date>2021-02-12T03:31:25Z</dc:date>
    </item>
    <item>
      <title>Re: Creating SelectionIds when you have two categories in your DataViewMapping</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Creating-SelectionIds-when-you-have-two-categories-in-your/m-p/1662343#M27815</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/397"&gt;@dm-p&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for the answer and the confirmation.&lt;/P&gt;&lt;P&gt;I normally also would use a forEach, but this code I copied from the documentation from Microsoft and modified it &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Paul&lt;/P&gt;</description>
      <pubDate>Fri, 12 Feb 2021 08:00:27 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Creating-SelectionIds-when-you-have-two-categories-in-your/m-p/1662343#M27815</guid>
      <dc:creator>paul-maessen</dc:creator>
      <dc:date>2021-02-12T08:00:27Z</dc:date>
    </item>
  </channel>
</rss>

