<?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: Field order change issue when using options.dataViews[0].table.rows in my custom visual in Developer</title>
    <link>https://community.fabric.microsoft.com/t5/Developer/Field-order-change-issue-when-using-options-dataViews-0-table/m-p/356444#M10613</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/17823"&gt;@v-viig&lt;/a&gt;, I'm using the below code to fetch data. Can you let me know how to use roles object here? Sorry, I'm new to JSON structures.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;for (var i = 0; i &amp;lt; rows.length; i++) {&lt;BR /&gt;var row = rows[i];&lt;BR /&gt;resultData.push({&lt;BR /&gt;Indicator: +row[0],&lt;BR /&gt;Target: +row[1],&lt;BR /&gt;Date: row[2].toString(),&lt;BR /&gt;});&lt;BR /&gt;&lt;BR /&gt;}&lt;/DIV&gt;</description>
    <pubDate>Mon, 12 Feb 2018 10:05:01 GMT</pubDate>
    <dc:creator>satishr</dc:creator>
    <dc:date>2018-02-12T10:05:01Z</dc:date>
    <item>
      <title>Field order change issue when using options.dataViews[0].table.rows in my custom visual</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Field-order-change-issue-when-using-options-dataViews-0-table/m-p/356292#M10606</link>
      <description>&lt;P&gt;Hi guys,&lt;/P&gt;&lt;P&gt;I have created a simple custom visual widget where I'm using&amp;nbsp;&lt;SPAN&gt;options&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;dataViews&lt;/SPAN&gt;&lt;SPAN&gt;[&lt;/SPAN&gt;&lt;SPAN&gt;0&lt;/SPAN&gt;&lt;SPAN&gt;].&lt;/SPAN&gt;&lt;SPAN&gt;table&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;rows to get data. The visual takes 3 fields as input - Actual, Target and Category. It works fine&amp;nbsp;when I input fields one by one to the widget but breaks if I input the data in different order even though I'm dragging the fields into correct input positions. It also breaks if I change the fields after creating the visual on the report. I think the issue is because I'm using row[0], row[1]....&amp;nbsp;to get the data. Is there a way to get data as row[actual], row[target].. or can I solve this problem in any other way?&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 12 Feb 2018 07:14:26 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Field-order-change-issue-when-using-options-dataViews-0-table/m-p/356292#M10606</guid>
      <dc:creator>satishr</dc:creator>
      <dc:date>2018-02-12T07:14:26Z</dc:date>
    </item>
    <item>
      <title>Re: Field order change issue when using options.dataViews[0].table.rows in my custom visual</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Field-order-change-issue-when-using-options-dataViews-0-table/m-p/356338#M10607</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/50316"&gt;@satishr&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You're able to get value index in the row by getting index from &lt;A href="https://github.com/Microsoft/PowerBI-visuals-tools/blob/master/templates/visuals/.api/v1.10.0/PowerBI-visuals.d.ts#L320" target="_blank"&gt;dataView.metadata.columns&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;Each column has the &lt;A href="https://github.com/Microsoft/PowerBI-visuals-tools/blob/d12d1b242afff14186f0507d99e3a392cd51d8ab/templates/visuals/.api/v1.10.0/PowerBI-visuals.d.ts#L352" target="_blank"&gt;roles&lt;/A&gt; object that indicates the role of this column (the roles contains column name).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="margin: 0in; font-family: Calibri; font-size: 11.0pt; color: #333333;"&gt;Ignat Vilesov,&lt;/P&gt;
&lt;P style="margin: 0in; font-family: Calibri; font-size: 11.0pt; color: #333333;"&gt;Software Engineer&lt;/P&gt;
&lt;P style="margin: 0in; font-family: Calibri; font-size: 11.0pt; color: #333333;"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="margin: 0in; font-family: Calibri; font-size: 11.0pt; color: #333333;"&gt;Microsoft Power BI Custom Visuals&lt;/P&gt;
&lt;P style="margin: 0in; font-family: Calibri; font-size: 11.0pt;"&gt;&lt;A href="mailto:pbicvsupport@microsoft.com" target="_blank"&gt;&lt;SPAN&gt;pbicvsupport@microsoft.com&lt;/SPAN&gt;&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 12 Feb 2018 08:10:18 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Field-order-change-issue-when-using-options-dataViews-0-table/m-p/356338#M10607</guid>
      <dc:creator>v-viig</dc:creator>
      <dc:date>2018-02-12T08:10:18Z</dc:date>
    </item>
    <item>
      <title>Re: Field order change issue when using options.dataViews[0].table.rows in my custom visual</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Field-order-change-issue-when-using-options-dataViews-0-table/m-p/356444#M10613</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/17823"&gt;@v-viig&lt;/a&gt;, I'm using the below code to fetch data. Can you let me know how to use roles object here? Sorry, I'm new to JSON structures.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;for (var i = 0; i &amp;lt; rows.length; i++) {&lt;BR /&gt;var row = rows[i];&lt;BR /&gt;resultData.push({&lt;BR /&gt;Indicator: +row[0],&lt;BR /&gt;Target: +row[1],&lt;BR /&gt;Date: row[2].toString(),&lt;BR /&gt;});&lt;BR /&gt;&lt;BR /&gt;}&lt;/DIV&gt;</description>
      <pubDate>Mon, 12 Feb 2018 10:05:01 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Field-order-change-issue-when-using-options-dataViews-0-table/m-p/356444#M10613</guid>
      <dc:creator>satishr</dc:creator>
      <dc:date>2018-02-12T10:05:01Z</dc:date>
    </item>
    <item>
      <title>Re: Field order change issue when using options.dataViews[0].table.rows in my custom visual</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Field-order-change-issue-when-using-options-dataViews-0-table/m-p/356473#M10615</link>
      <description>&lt;P&gt;Please use this code snippet to parse values from table mapping:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;    export interface ColumnGroup {
        [columnName: string]: number | Date | string;
    }

    function getColumnGroupByRole(
        columns: DataViewMetadataColumn[],
        row: DataViewTableRow
    &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt; ColumnGroup {
        const columnGroup: ColumnGroup = {};

        row.forEach((value: any, valueIndex: number) =&amp;gt; {
            const column: DataViewMetadataColumn = columns[valueIndex];

            Object.keys(columns[valueIndex].roles)
                .forEach((roleName: string) =&amp;gt; {
                    columnGroup[roleName] = value;
                });
        });

        return columnGroup;
    }

    function parseData(dataView: DataView) {
        const data: any[] = [];

        dataView.table.rows.forEach((row: DataViewTableRow) =&amp;gt; {
            const columns = getColumnGroupByRole(dataView.metadata.columns, row);

            data.push({
                Indicator: +columns["Indicator"],
                Target: +columns["Target"],
                Date: columns["Date"]
                    ? columns["Date"].toString()
                    : null
            });
        });

        return data;
    }&lt;/PRE&gt;
&lt;P style="margin: 0in; font-family: Calibri; font-size: 11.0pt; color: #333333;"&gt;Ignat Vilesov,&lt;/P&gt;
&lt;P style="margin: 0in; font-family: Calibri; font-size: 11.0pt; color: #333333;"&gt;Software Engineer&lt;/P&gt;
&lt;P style="margin: 0in; font-family: Calibri; font-size: 11.0pt; color: #333333;"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="margin: 0in; font-family: Calibri; font-size: 11.0pt; color: #333333;"&gt;Microsoft Power BI Custom Visuals&lt;/P&gt;
&lt;P style="margin: 0in; font-family: Calibri; font-size: 11.0pt;"&gt;&lt;A href="mailto:pbicvsupport@microsoft.com" target="_blank"&gt;&lt;SPAN&gt;pbicvsupport@microsoft.com&lt;/SPAN&gt;&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 12 Feb 2018 10:45:12 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Field-order-change-issue-when-using-options-dataViews-0-table/m-p/356473#M10615</guid>
      <dc:creator>v-viig</dc:creator>
      <dc:date>2018-02-12T10:45:12Z</dc:date>
    </item>
  </channel>
</rss>

