<?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: How to implement selections based on a categorical dataviewmapping with multiple fields in Custom Visuals Development Discussion</title>
    <link>https://community.fabric.microsoft.com/t5/Custom-Visuals-Development/How-to-implement-selections-based-on-a-categorical/m-p/1013565#M3087</link>
    <description>&lt;P&gt;Hi Daniel,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have tried that approach too...&amp;nbsp;&lt;/P&gt;&lt;P&gt;I cannot use all together because I need to be sending an array to each datapoint since I have several category fields right?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is the output of console.log for the selection ID:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;e {measures: Array(0), dataMap: {…}, key: "{"Customers.Is Auto":[{"identityIndex":0}]}[]"}
VM47262:117515 e {measures: Array(0), dataMap: {…}, key: "{"Customers.Is Malls":[{"identityIndex":0}]}[]"}
VM47262:117515 e {measures: Array(0), dataMap: {…}, key: "{"Customers.Is Real Estate":[{"identityIndex":0}]}[]"}
VM47262:117515 e {measures: Array(0), dataMap: {…}, key: "{"Customers.Is Retail":[{"identityIndex":0}]}[]"}
VM47262:117515 e {measures: Array(0), dataMap: {…}, key: "{"Customers.Is Auto":[{"identityIndex":1}]}[]"}
VM47262:117515 e {measures: Array(0), dataMap: {…}, key: "{"Customers.Is Malls":[{"identityIndex":1}]}[]"}
VM47262:117515 e {measures: Array(0), dataMap: {…}, key: "{"Customers.Is Real Estate":[{"identityIndex":1}]}[]"}
VM47262:117515 e {measures: Array(0), dataMap: {…}, key: "{"Customers.Is Retail":[{"identityIndex":1}]}[]"}
VM47262:117515 e {measures: Array(0), dataMap: {…}, key: "{"Customers.Is Auto":[{"identityIndex":2}]}[]"}
VM47262:117515 e {measures: Array(0), dataMap: {…}, key: "{"Customers.Is Malls":[{"identityIndex":2}]}[]"}
VM47262:117515 e {measures: Array(0), dataMap: {…}, key: "{"Customers.Is Real Estate":[{"identityIndex":2}]}[]"}
VM47262:117515 e {measures: Array(0), dataMap: {…}, key: "{"Customers.Is Retail":[{"identityIndex":2}]}[]"}
...
...
...&lt;/LI-CODE&gt;</description>
    <pubDate>Tue, 07 Apr 2020 20:09:55 GMT</pubDate>
    <dc:creator>djpirra</dc:creator>
    <dc:date>2020-04-07T20:09:55Z</dc:date>
    <item>
      <title>How to implement selections based on a categorical dataviewmapping with multiple fields</title>
      <link>https://community.fabric.microsoft.com/t5/Custom-Visuals-Development/How-to-implement-selections-based-on-a-categorical/m-p/1013441#M3084</link>
      <description>&lt;P&gt;Hi everyone,&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Been trying to implement selections on my custom visual but somehow I cannot seem to make it work.&lt;/P&gt;&lt;P&gt;Context drillthrough works fine but the item selection just does not seem to be working.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Currently I am testing with 4 fields on the category and one measure only.&lt;/P&gt;&lt;P&gt;The logic that I have implemented is the following:&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;- For each of the measure values iterate through the 4 categories and add a new selection ID as for example:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;for (var _i = 0; _i &amp;lt; categoricalDataView.values[0].values.length; _i++) {
...
...
  categoricalDataView.categories.forEach((column: DataViewCategoryColumn) =&amp;gt; {     
     const categorySelectionId = this.host.createSelectionIdBuilder();
     categorySelectionId.withCategory(column, _i);
     categorySelectionId.withMeasure(values[0].source.queryName);
     _selectionIds.push(categorySelectionId.createSelectionId());
  });
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What is wrong here?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you&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;</description>
      <pubDate>Tue, 07 Apr 2020 18:22:35 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Custom-Visuals-Development/How-to-implement-selections-based-on-a-categorical/m-p/1013441#M3084</guid>
      <dc:creator>djpirra</dc:creator>
      <dc:date>2020-04-07T18:22:35Z</dc:date>
    </item>
    <item>
      <title>Re: How to implement selections based on a categorical dataviewmapping with multiple fields</title>
      <link>https://community.fabric.microsoft.com/t5/Custom-Visuals-Development/How-to-implement-selections-based-on-a-categorical/m-p/1013550#M3085</link>
      <description>&lt;P&gt;Hi &lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="217855" data-lia-user-login="djpirra" class="lia-mention lia-mention-user"&gt;djpirra&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;It's difficult to analyse 100% without seeing the rest of your code, but typically the methods you're calling against &lt;FONT face="courier new,courier"&gt;categorySelectionId&lt;/FONT&gt; to create your &lt;FONT face="courier new,courier"&gt;selectionId&lt;/FONT&gt; should usually be chained together.&lt;/P&gt;
&lt;P&gt;Can you try the following and see if it works?&lt;/P&gt;
&lt;LI-CODE lang="javascript"&gt;categoricalDataView.categories.forEach((column: DataViewCategoryColumn) =&amp;gt; {     
     const categorySelectionId = this.host.createSelectionIdBuilder();
     _selectionIds.push(
         categorySelectionId
            .withCategory(column, _i)
            .withMeasure(values[0].source.queryName)
            .createSelectionId()
     );
  });&lt;/LI-CODE&gt;
&lt;P&gt;If this isn't working, we might need to get a bit more detail, but let's start here.&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;Daniel&lt;/P&gt;</description>
      <pubDate>Tue, 07 Apr 2020 19:56:16 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Custom-Visuals-Development/How-to-implement-selections-based-on-a-categorical/m-p/1013550#M3085</guid>
      <dc:creator>dm-p</dc:creator>
      <dc:date>2020-04-07T19:56:16Z</dc:date>
    </item>
    <item>
      <title>Re: How to implement selections based on a categorical dataviewmapping with multiple fields</title>
      <link>https://community.fabric.microsoft.com/t5/Custom-Visuals-Development/How-to-implement-selections-based-on-a-categorical/m-p/1013565#M3087</link>
      <description>&lt;P&gt;Hi Daniel,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have tried that approach too...&amp;nbsp;&lt;/P&gt;&lt;P&gt;I cannot use all together because I need to be sending an array to each datapoint since I have several category fields right?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is the output of console.log for the selection ID:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;e {measures: Array(0), dataMap: {…}, key: "{"Customers.Is Auto":[{"identityIndex":0}]}[]"}
VM47262:117515 e {measures: Array(0), dataMap: {…}, key: "{"Customers.Is Malls":[{"identityIndex":0}]}[]"}
VM47262:117515 e {measures: Array(0), dataMap: {…}, key: "{"Customers.Is Real Estate":[{"identityIndex":0}]}[]"}
VM47262:117515 e {measures: Array(0), dataMap: {…}, key: "{"Customers.Is Retail":[{"identityIndex":0}]}[]"}
VM47262:117515 e {measures: Array(0), dataMap: {…}, key: "{"Customers.Is Auto":[{"identityIndex":1}]}[]"}
VM47262:117515 e {measures: Array(0), dataMap: {…}, key: "{"Customers.Is Malls":[{"identityIndex":1}]}[]"}
VM47262:117515 e {measures: Array(0), dataMap: {…}, key: "{"Customers.Is Real Estate":[{"identityIndex":1}]}[]"}
VM47262:117515 e {measures: Array(0), dataMap: {…}, key: "{"Customers.Is Retail":[{"identityIndex":1}]}[]"}
VM47262:117515 e {measures: Array(0), dataMap: {…}, key: "{"Customers.Is Auto":[{"identityIndex":2}]}[]"}
VM47262:117515 e {measures: Array(0), dataMap: {…}, key: "{"Customers.Is Malls":[{"identityIndex":2}]}[]"}
VM47262:117515 e {measures: Array(0), dataMap: {…}, key: "{"Customers.Is Real Estate":[{"identityIndex":2}]}[]"}
VM47262:117515 e {measures: Array(0), dataMap: {…}, key: "{"Customers.Is Retail":[{"identityIndex":2}]}[]"}
...
...
...&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 07 Apr 2020 20:09:55 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Custom-Visuals-Development/How-to-implement-selections-based-on-a-categorical/m-p/1013565#M3087</guid>
      <dc:creator>djpirra</dc:creator>
      <dc:date>2020-04-07T20:09:55Z</dc:date>
    </item>
    <item>
      <title>Re: How to implement selections based on a categorical dataviewmapping with multiple fields</title>
      <link>https://community.fabric.microsoft.com/t5/Custom-Visuals-Development/How-to-implement-selections-based-on-a-categorical/m-p/1013593#M3088</link>
      <description>&lt;P&gt;Hi &lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="217855" data-lia-user-login="djpirra" class="lia-mention lia-mention-user"&gt;djpirra&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;Based on my understanding of the original code, the output looks okay, although you typically shouldn't need an array for each data point; just a &lt;FONT face="courier new,courier"&gt;selectionId&lt;/FONT&gt;. However,this will depend on how you are mapping your data, and how you are intending to use it within the visual. I have perhaps wrongly assumed you just wanted an array of all &lt;FONT face="courier new,courier"&gt;selectionIds&lt;/FONT&gt; available.&lt;/P&gt;
&lt;P&gt;Normally, I might have an object array of my categories/values, with the &lt;FONT face="courier new,courier"&gt;selectionId&lt;/FONT&gt; as an attribute of that particular element, but again, this would depend on my intended use case.&lt;/P&gt;
&lt;P&gt;Are you able to share your code at all? It might be more helpful if I can see how you're building your view model and how you are using it when you draw your visual. It might be that we need to make some changes elsewhere and it would be good if I can provide a more targeted answer for you.&lt;/P&gt;
&lt;P&gt;Thanks,&lt;/P&gt;
&lt;P&gt;Daniel&lt;/P&gt;</description>
      <pubDate>Tue, 07 Apr 2020 20:31:02 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Custom-Visuals-Development/How-to-implement-selections-based-on-a-categorical/m-p/1013593#M3088</guid>
      <dc:creator>dm-p</dc:creator>
      <dc:date>2020-04-07T20:31:02Z</dc:date>
    </item>
    <item>
      <title>Re: How to implement selections based on a categorical dataviewmapping with multiple fields</title>
      <link>https://community.fabric.microsoft.com/t5/Custom-Visuals-Development/How-to-implement-selections-based-on-a-categorical/m-p/1014464#M3089</link>
      <description>&lt;P&gt;Hi &lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="217855" data-lia-user-login="djpirra" class="lia-mention lia-mention-user"&gt;djpirra&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;In terms of selections with the categorical &lt;FONT face="courier new,courier"&gt;dataViewMapping&lt;/FONT&gt;, you can generate &lt;FONT face="courier new,courier"&gt;selectionIds&lt;/FONT&gt; for all values of 1 category x 1 grouping (series) x 1 measure. You would add a &lt;FONT face="courier new,courier"&gt;.withSeries()&lt;/FONT&gt; to your chain to include the grouping, similar to the &lt;A href="https://docs.microsoft.com/en-us/power-bi/developer/visuals/selection-api" target="_self"&gt;worked example in the MS doc here&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;I have also used this pattern in one of my visuals - &lt;A href="https://github.com/dm-p/powerbi-visuals-smlc/blob/master/src/viewModel/ViewModelHandler.ts#L280" target="_self"&gt;this can be seen in how I map my view model here&lt;/A&gt; (and here's the &lt;A href="https://github.com/dm-p/powerbi-visuals-smlc/blob/master/capabilities.json#L1210" target="_self"&gt;&lt;FONT face="courier new,courier"&gt;dataViewMapping&lt;/FONT&gt; in the &lt;FONT face="courier new,courier"&gt;capabilities&lt;/FONT&gt;&lt;/A&gt;).&lt;/P&gt;
&lt;P&gt;If you want to create a &lt;FONT face="courier new,courier"&gt;selectionId&lt;/FONT&gt; for a context of more categories than this, then you may need to use a &lt;FONT face="courier new,courier"&gt;table&lt;/FONT&gt; or &lt;FONT face="courier new,courier"&gt;matrix&lt;/FONT&gt; &lt;FONT face="courier new,courier"&gt;dataViewMapping&lt;/FONT&gt; (although if you wish to make use of&lt;A href="https://docs.microsoft.com/en-us/power-bi/developer/visuals/highlight" target="_self"&gt; highlighting in your visual, only &lt;FONT face="courier new,courier"&gt;categorical&lt;/FONT&gt; and &lt;FONT face="courier new,courier"&gt;matrix&lt;/FONT&gt; would be viable choices&lt;/A&gt;).&lt;/P&gt;
&lt;P&gt;If you'd want to proceed with using the &lt;FONT face="courier new,courier"&gt;categorical&lt;/FONT&gt; approach, we should have a look at your code to see if it's possible to re-structure your capabilities or view model to see if we can make valid &lt;FONT face="courier new,courier"&gt;selectionIds&lt;/FONT&gt; work in this case.&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;Daniel&lt;/P&gt;</description>
      <pubDate>Wed, 08 Apr 2020 07:52:19 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Custom-Visuals-Development/How-to-implement-selections-based-on-a-categorical/m-p/1014464#M3089</guid>
      <dc:creator>dm-p</dc:creator>
      <dc:date>2020-04-08T07:52:19Z</dc:date>
    </item>
    <item>
      <title>Re: How to implement selections based on a categorical dataviewmapping with multiple fields</title>
      <link>https://community.fabric.microsoft.com/t5/Custom-Visuals-Development/How-to-implement-selections-based-on-a-categorical/m-p/1014990#M3091</link>
      <description>&lt;P&gt;Hi Daniel,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is what I have tried and also below is the output of one of the generated / triggered selectionIDs on the current setup.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Scenario 1:&lt;/P&gt;&lt;P&gt;- Created selectionId based on measure and 4 entries in categories ( current scenario )&lt;/P&gt;&lt;P&gt;- Created an array of selectionIds based on measure and each of the categories ( since apparently the selectionManager can receive an array of selectionIds )&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;e {measures: Array(1), dataMap: {…}, key: "{"XXXX.Is Auto":[{"identityIndex":11}],"Custo…tityIndex":11}]}["KPIs.# Active Customers"]"}
measures: ["KPIs.# Active Customers"]
dataMap:
XXXX.Is Auto: Array(1)
0: {identityIndex: 11}
length: 1
__proto__: Array(0)
XXXX.Is Malls: Array(1)
0: {identityIndex: 11}
length: 1
__proto__: Array(0)
XXXX.Is Real Estate: Array(1)
0: {identityIndex: 11}
length: 1
__proto__: Array(0)
XXXX.Is Retail: Array(1)
0: {identityIndex: 11}
length: 1
__proto__: Array(0)
__proto__: Object
key: "{"XXXX.Is Auto":[{"identityIndex":11}],"XXXX.Is Malls":[{"identityIndex":11}],"XXXX.Is Real Estate":[{"identityIndex":11}],"XXXX.Is Retail":[{"identityIndex":11}]}["KPIs.# Active Customers"]"
__proto__: Object&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 08 Apr 2020 11:12:07 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Custom-Visuals-Development/How-to-implement-selections-based-on-a-categorical/m-p/1014990#M3091</guid>
      <dc:creator>djpirra</dc:creator>
      <dc:date>2020-04-08T11:12:07Z</dc:date>
    </item>
    <item>
      <title>Re: How to implement selections based on a categorical dataviewmapping with multiple fields</title>
      <link>https://community.fabric.microsoft.com/t5/Custom-Visuals-Development/How-to-implement-selections-based-on-a-categorical/m-p/1015090#M3092</link>
      <description>&lt;P&gt;Hey everyone.&lt;BR /&gt;Was able to make it work....&lt;/P&gt;&lt;P&gt;Everything was ok with the code except that I had this option on my capabilities file:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;"general": {
            "displayName": "General",
            "displayNameKey": "formattingGeneral",
            "properties": {
                "filter": {
                    "type": {
                        "filter": true
                    }
                }
            }
        },&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Apparently this disables the normal behavior.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Wed, 08 Apr 2020 12:11:16 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Custom-Visuals-Development/How-to-implement-selections-based-on-a-categorical/m-p/1015090#M3092</guid>
      <dc:creator>djpirra</dc:creator>
      <dc:date>2020-04-08T12:11:16Z</dc:date>
    </item>
  </channel>
</rss>

