<?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: SelectionIds are incorrect - table data view mapping in Developer</title>
    <link>https://community.fabric.microsoft.com/t5/Developer/SelectionIds-are-incorrect-table-data-view-mapping/m-p/2096692#M32021</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/124852"&gt;@giammariam&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I think you can try Group function between two visuals. Just select two visuals, right click and select Group. Then you can combine two visuals as one.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;BR /&gt;Rico Zhou&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.&lt;/P&gt;</description>
    <pubDate>Fri, 24 Sep 2021 10:04:10 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2021-09-24T10:04:10Z</dc:date>
    <item>
      <title>SelectionIds are incorrect - table data view mapping</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/SelectionIds-are-incorrect-table-data-view-mapping/m-p/2089356#M31934</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a custom visual that is a combination of a line chart and Gantt. I am using table data view mapping. I'm using .withTable() to generate my selectionIds. Each datapoint is given its own selectionId. Each Gantt time-series block is made up of multiple datapoints. For each block, the individual selectionIds are stored in an array. When I select a block (see second screenshot below), the correct number of datapoints are selected in external visuals, but the data points themselves are incorrect. For example: Item 1, Phase 2 is selected and is made up of 161 datapoints, but the table has datapoints selected that are for different items and phases. There's probably something pretty obvious that I'm missing, but I'm not sure what it is.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If anyone is willing to take a look, shoot me a message and I'll send you my code and a demo .pbix.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="giammariam_2-1632246466891.png" style="width: 400px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/597845i4C2D1CF110BBFF93/image-size/medium?v=v2&amp;amp;px=400" role="button" title="giammariam_2-1632246466891.png" alt="giammariam_2-1632246466891.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="giammariam_0-1632246411240.png" style="width: 400px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/597842i1670DE51574BE94E/image-size/medium?v=v2&amp;amp;px=400" role="button" title="giammariam_0-1632246411240.png" alt="giammariam_0-1632246411240.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is my code that generates the selectionIds and stores them in each time-series block.&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt; private static getGanttDataPoints(options: VisualUpdateOptions, highlights: powerbi.PrimitiveValue[], viewModel: IViewModel, host: IVisualHost): IGanttDataPoint[] {
        let rows: powerbi.DataViewTableRow[] = options.dataViews[0].table.rows;
        let fieldIndices: IFieldIndices = viewModel.fieldIndices;

        let ganttDataPoints: IGanttDataPoint[] =
            rows.map((d: powerbi.DataViewTableRow, i: number) =&amp;gt; ({
                axes: +this.rowToDataRoleValue(rows[i], fieldIndices.axisIndex),
                ganttItem: this.rowToDataRoleValue(rows[i], fieldIndices.ganttItemIndex),
                ganttLegend: this.rowToDataRoleValue(rows[i], fieldIndices.ganttLegendIndex),
                ganttBlock: this.rowToDataRoleValue(rows[i], fieldIndices.ganttBlockLabelIndex),
                ganttItemSort: +this.rowToDataRoleValue(rows[i], fieldIndices.ganttItemSortIndex),
                ordinalSeries: null,
                selectionId: host.createSelectionIdBuilder()
                    .withTable(options.dataViews[0].table, i)
                    .createSelectionId(),
                identityIndices: i,
                start: null,
                end: null,
                color: null
            }))
                .sort((a: IGanttDataPoint, b: IGanttDataPoint) =&amp;gt; a.ganttItem.localeCompare(b.ganttItem) || +a.axes - +b.axes);

        //get the ordinalseries values
        ganttDataPoints
            .forEach((d: IGanttDataPoint, i: number, s: IGanttDataPoint[]) =&amp;gt; {
                if (i === 0) { //first row gets ordinalseries = 1 
                    d.ordinalSeries = 1;
                } else if (s[i - 1].ganttItem === d.ganttItem //if current row has the same ganttitem and ganttlegend as previous row, give it the same ordinalseries
                    &amp;amp;&amp;amp; s[i - 1].ganttLegend === d.ganttLegend) {
                    d.ordinalSeries = s[i - 1].ordinalSeries;
                } else { //otherwise increase the ordinalseries by 1
                    d.ordinalSeries = s[i - 1].ordinalSeries + 1;
                }
            });

        //reduce the dataset into time-series blocks
        //populate remaining datapoints
        ganttDataPoints = ganttDataPoints
            .reduce((blocks: IGanttDataPoint[], ganttData: IGanttDataPoint, i: number, s: IGanttDataPoint[]) =&amp;gt; {
                if (!blocks[ganttData.ordinalSeries]) {
                    ganttData.start = &amp;lt;number&amp;gt;ganttData.axes
                    ganttData.end = max(ganttDataPoints.filter((d: IGanttDataPoint) =&amp;gt; +d.ordinalSeries === +ganttData.ordinalSeries).map((d: IGanttDataPoint) =&amp;gt; &amp;lt;number&amp;gt;d.axes))
                    ganttData.axes = &amp;lt;number[]&amp;gt;s.filter((d: IGanttDataPoint) =&amp;gt; +d.ordinalSeries === +ganttData.ordinalSeries).map((d: IGanttDataPoint) =&amp;gt; d.axes)
                    ganttData.identityIndices = &amp;lt;any&amp;gt;s.filter((d: IGanttDataPoint) =&amp;gt; +d.ordinalSeries === +ganttData.ordinalSeries).map((d: IGanttDataPoint) =&amp;gt; d.identityIndices)
                    ganttData.selectionId = &amp;lt;any&amp;gt;s.filter((d: IGanttDataPoint) =&amp;gt; +d.ordinalSeries === +ganttData.ordinalSeries).map((d: IGanttDataPoint) =&amp;gt; d.selectionId)
                    ganttData.color = ganttData.ganttLegend ? viewModel.legendItems.gantt.filter((l: IGanttLegendItem) =&amp;gt; l.legendItem === ganttData.ganttLegend)[0].color : viewModel.settings.colorSelector.ganttColor0
                    blocks[ganttData.ordinalSeries] = ganttData;
                }
                return blocks;
            }, [])
            .filter((d, i) =&amp;gt; i != 0); //above reduce starts with an empty array, remove 

        return ganttDataPoints;
    }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;A href="https://community.powerbi.com/t5/user/viewprofilepage/user-id/17823" target="_blank"&gt;@v-viig,&amp;nbsp;&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 21 Sep 2021 17:54:32 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/SelectionIds-are-incorrect-table-data-view-mapping/m-p/2089356#M31934</guid>
      <dc:creator>giammariam</dc:creator>
      <dc:date>2021-09-21T17:54:32Z</dc:date>
    </item>
    <item>
      <title>Re: SelectionIds are incorrect - table data view mapping</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/SelectionIds-are-incorrect-table-data-view-mapping/m-p/2096692#M32021</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/124852"&gt;@giammariam&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I think you can try Group function between two visuals. Just select two visuals, right click and select Group. Then you can combine two visuals as one.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;BR /&gt;Rico Zhou&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.&lt;/P&gt;</description>
      <pubDate>Fri, 24 Sep 2021 10:04:10 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/SelectionIds-are-incorrect-table-data-view-mapping/m-p/2096692#M32021</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-09-24T10:04:10Z</dc:date>
    </item>
    <item>
      <title>Re: SelectionIds are incorrect - table data view mapping</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/SelectionIds-are-incorrect-table-data-view-mapping/m-p/2097121#M32025</link>
      <description>&lt;P&gt;Thanks. The line and gantt is one custom visual.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 24 Sep 2021 13:08:23 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/SelectionIds-are-incorrect-table-data-view-mapping/m-p/2097121#M32025</guid>
      <dc:creator>giammariam</dc:creator>
      <dc:date>2021-09-24T13:08:23Z</dc:date>
    </item>
  </channel>
</rss>

