<?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: Adding index column based on another query, issues with data types in Dataflow</title>
    <link>https://community.fabric.microsoft.com/t5/Dataflow/Adding-index-column-based-on-another-query-issues-with-data/m-p/3771145#M2495</link>
    <description>&lt;P&gt;Yes, they both were as default. Changed the MaxKey_Accounts query to not be, and it worked! Thanks a lot! &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;BR /&gt;&lt;BR /&gt;Note: it did however require some other troubleshooting as it did not work at first, but that was due to the DROP and CREATE table functions in the warehouse. When I first created the tables I used:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;columnName varchar NULL,&lt;/LI-CODE&gt;&lt;P&gt;... and for reasons I did a DROP and CREATE in which the automated code created did this:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;columnName varchar(1) NULL,&lt;/LI-CODE&gt;&lt;P&gt;... which caused other insert errors since all data was more than 1 varchar big (not related to the index column) but I'm leaving this info here for others so they don't make the same mistake I did.&lt;BR /&gt;&lt;BR /&gt;Follow-up question: if staging the MaxKey_Accounts returns it as a table in the index column creation, how come Number.From did not work in converting it into a number?&lt;/P&gt;</description>
    <pubDate>Mon, 18 Mar 2024 10:21:02 GMT</pubDate>
    <dc:creator>nioj2S2</dc:creator>
    <dc:date>2024-03-18T10:21:02Z</dc:date>
    <item>
      <title>Adding index column based on another query, issues with data types</title>
      <link>https://community.fabric.microsoft.com/t5/Dataflow/Adding-index-column-based-on-another-query-issues-with-data/m-p/3760529#M2419</link>
      <description>&lt;P&gt;Hello!&lt;BR /&gt;&lt;BR /&gt;I am trying to do a workaround for the missing IDENTITY column in my Fabric warehouse in order to have a surrogate key.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In the DW I have column [surrogateKey] in the empty accounts table. The new key should be based on the max existing key+1 and then incrementally add 1.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;In the Dataflow gen2 I have a query MaxKey_Accounts to first get the max value from the surrogateKey column (or return 0 if no value exists):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;let
Source = Fabric.Warehouse([]),
#"Navigation 1" = Source{[workspaceId = "yyy"]}[Data],
#"Navigation 2" = #"Navigation 1"{[warehouseId = "xxx"]}[Data],
#"Navigation 3" = #"Navigation 2"{[Schema = "zzz", Item = "accounts"]}[Data],
#"Removed other columns" = Table.SelectColumns(#"Navigation 3", {"surrogateKey"}),
#"Calculated maximum" = if List.Max(#"Removed other columns"[surrogateKey]) is null then 0 else List.Max(#"Removed other columns"[surrogateKey])
in
#"Calculated maximum"&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This saves as a decimal based on the "1.2" icon next to the name under "Queries" field to the left.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;... then I want to use this result as a base for the identity in another query (code excerpt):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Table.AddIndexColumn(#"Changed column type 1", "surrogateKey", MaxKey_Accounts+1, 1)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Gives error: "&lt;SPAN class=""&gt;We cannot apply operator + to types Table and Number&lt;/SPAN&gt;."&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have tried casting the MaxKey_Accounts as well:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Table.AddIndexColumn(#"Changed column type 1", "surrogateKey", Number.From(MaxKey_Accounts)+1, 1)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Gives error "&lt;SPAN class=""&gt;We couldn't convert to Number&lt;/SPAN&gt;."&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And this way too:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Table.AddIndexColumn(#"Changed column type 1", "surrogateKey", Table.Max(MaxKey_Accounts)+1, 1)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;Gives error: "We cannot convert a value of type Table to type Text.&lt;/SPAN&gt;"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So, how can I take the max value from existing DW table and use that in creating an index column for new data into that table?&lt;BR /&gt;&lt;BR /&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Wed, 13 Mar 2024 11:52:10 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Dataflow/Adding-index-column-based-on-another-query-issues-with-data/m-p/3760529#M2419</guid>
      <dc:creator>nioj2S2</dc:creator>
      <dc:date>2024-03-13T11:52:10Z</dc:date>
    </item>
    <item>
      <title>Re: Adding index column based on another query, issues with data types</title>
      <link>https://community.fabric.microsoft.com/t5/Dataflow/Adding-index-column-based-on-another-query-issues-with-data/m-p/3762358#M2460</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="704946" data-lia-user-login="nioj2S2" class="lia-mention lia-mention-user"&gt;nioj2S2&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks for using Microsoft Fabric Community.&lt;/P&gt;
&lt;P&gt;Apologies for the issue that you are facing.&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;This might require a deeper investigation from our engineering team to help you better.&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;Please go ahead and raise a support ticket to reach our support team:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;A href="https://support.fabric.microsoft.com/support" target="_blank" rel="noopener nofollow noreferrer"&gt;https://support.fabric.microsoft.com/support&lt;/A&gt;&lt;BR /&gt;Please provide the ticket number here as we can keep an eye on it.&lt;BR /&gt;&lt;BR /&gt;Thanks&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 14 Mar 2024 05:51:30 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Dataflow/Adding-index-column-based-on-another-query-issues-with-data/m-p/3762358#M2460</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-03-14T05:51:30Z</dc:date>
    </item>
    <item>
      <title>Re: Adding index column based on another query, issues with data types</title>
      <link>https://community.fabric.microsoft.com/t5/Dataflow/Adding-index-column-based-on-another-query-issues-with-data/m-p/3762861#M2463</link>
      <description>&lt;P&gt;i am facing exactly the same issue!&lt;/P&gt;</description>
      <pubDate>Thu, 14 Mar 2024 08:17:32 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Dataflow/Adding-index-column-based-on-another-query-issues-with-data/m-p/3762861#M2463</guid>
      <dc:creator>mandania</dc:creator>
      <dc:date>2024-03-14T08:17:32Z</dc:date>
    </item>
    <item>
      <title>Re: Adding index column based on another query, issues with data types</title>
      <link>https://community.fabric.microsoft.com/t5/Dataflow/Adding-index-column-based-on-another-query-issues-with-data/m-p/3767609#M2486</link>
      <description>&lt;P&gt;are any of your queries set to be staged? specifically the&amp;nbsp;MaxKey_Accounts query&lt;/P&gt;</description>
      <pubDate>Fri, 15 Mar 2024 21:00:13 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Dataflow/Adding-index-column-based-on-another-query-issues-with-data/m-p/3767609#M2486</guid>
      <dc:creator>miguel</dc:creator>
      <dc:date>2024-03-15T21:00:13Z</dc:date>
    </item>
    <item>
      <title>Re: Adding index column based on another query, issues with data types</title>
      <link>https://community.fabric.microsoft.com/t5/Dataflow/Adding-index-column-based-on-another-query-issues-with-data/m-p/3770299#M2490</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="704946" data-lia-user-login="nioj2S2" class="lia-mention lia-mention-user"&gt;nioj2S2&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;We haven’t heard from you on the last response and was just checking back to see if you got a chance to create a support ticket. If yes please provide the details here. Otherwise, will respond back with the more details and we will try to help. &lt;BR /&gt;Thanks&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 18 Mar 2024 07:00:01 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Dataflow/Adding-index-column-based-on-another-query-issues-with-data/m-p/3770299#M2490</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-03-18T07:00:01Z</dc:date>
    </item>
    <item>
      <title>Re: Adding index column based on another query, issues with data types</title>
      <link>https://community.fabric.microsoft.com/t5/Dataflow/Adding-index-column-based-on-another-query-issues-with-data/m-p/3770712#M2492</link>
      <description>&lt;P&gt;Hi Anonymous&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Yes, I have been in call with support, awaiting their response after the information I provided them with.&lt;/P&gt;</description>
      <pubDate>Mon, 18 Mar 2024 08:16:13 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Dataflow/Adding-index-column-based-on-another-query-issues-with-data/m-p/3770712#M2492</guid>
      <dc:creator>nioj2S2</dc:creator>
      <dc:date>2024-03-18T08:16:13Z</dc:date>
    </item>
    <item>
      <title>Re: Adding index column based on another query, issues with data types</title>
      <link>https://community.fabric.microsoft.com/t5/Dataflow/Adding-index-column-based-on-another-query-issues-with-data/m-p/3770796#M2493</link>
      <description>&lt;P&gt;Hi &lt;SPAN&gt;nioj2S2, would you mind checking the previous reply that I provided?&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;This might not require the assistance of the support team.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Copying the previous reply that I left:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;are any of your queries set to be staged? specifically the&amp;nbsp;MaxKey_Accounts query&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 18 Mar 2024 08:44:49 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Dataflow/Adding-index-column-based-on-another-query-issues-with-data/m-p/3770796#M2493</guid>
      <dc:creator>miguel</dc:creator>
      <dc:date>2024-03-18T08:44:49Z</dc:date>
    </item>
    <item>
      <title>Re: Adding index column based on another query, issues with data types</title>
      <link>https://community.fabric.microsoft.com/t5/Dataflow/Adding-index-column-based-on-another-query-issues-with-data/m-p/3771145#M2495</link>
      <description>&lt;P&gt;Yes, they both were as default. Changed the MaxKey_Accounts query to not be, and it worked! Thanks a lot! &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;BR /&gt;&lt;BR /&gt;Note: it did however require some other troubleshooting as it did not work at first, but that was due to the DROP and CREATE table functions in the warehouse. When I first created the tables I used:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;columnName varchar NULL,&lt;/LI-CODE&gt;&lt;P&gt;... and for reasons I did a DROP and CREATE in which the automated code created did this:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;columnName varchar(1) NULL,&lt;/LI-CODE&gt;&lt;P&gt;... which caused other insert errors since all data was more than 1 varchar big (not related to the index column) but I'm leaving this info here for others so they don't make the same mistake I did.&lt;BR /&gt;&lt;BR /&gt;Follow-up question: if staging the MaxKey_Accounts returns it as a table in the index column creation, how come Number.From did not work in converting it into a number?&lt;/P&gt;</description>
      <pubDate>Mon, 18 Mar 2024 10:21:02 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Dataflow/Adding-index-column-based-on-another-query-issues-with-data/m-p/3771145#M2495</guid>
      <dc:creator>nioj2S2</dc:creator>
      <dc:date>2024-03-18T10:21:02Z</dc:date>
    </item>
    <item>
      <title>Re: Adding index column based on another query, issues with data types</title>
      <link>https://community.fabric.microsoft.com/t5/Dataflow/Adding-index-column-based-on-another-query-issues-with-data/m-p/3772092#M2496</link>
      <description>&lt;P&gt;when you stage a query it needs to be saved as a table. If you had a scalar value, like a number, simply referring to that query would yield the scalar value (Number). However, if its a table (like it was in this case because the query was staged) then you'd need to do the table navigation to reach the value that you're looking for. It could be something like QueryName[ColumnName]{0} where the 0 indicates that you just want the first row.&lt;/P&gt;
&lt;P&gt;Number.From works against scalar values and not complex ones (like records, tables, lists and such). More info on the signature of the function below:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://learn.microsoft.com/en-us/powerquery-m/number-from" target="_blank"&gt;Number.From - PowerQuery M | Microsoft Learn&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 18 Mar 2024 15:47:03 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Dataflow/Adding-index-column-based-on-another-query-issues-with-data/m-p/3772092#M2496</guid>
      <dc:creator>miguel</dc:creator>
      <dc:date>2024-03-18T15:47:03Z</dc:date>
    </item>
    <item>
      <title>Re: Adding index column based on another query, issues with data types</title>
      <link>https://community.fabric.microsoft.com/t5/Dataflow/Adding-index-column-based-on-another-query-issues-with-data/m-p/3774921#M2512</link>
      <description>&lt;P&gt;Thanks a lot! &lt;span class="lia-unicode-emoji" title=":grinning_face_with_smiling_eyes:"&gt;😄&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 19 Mar 2024 11:12:08 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Dataflow/Adding-index-column-based-on-another-query-issues-with-data/m-p/3774921#M2512</guid>
      <dc:creator>nioj2S2</dc:creator>
      <dc:date>2024-03-19T11:12:08Z</dc:date>
    </item>
  </channel>
</rss>

