<?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: List.Transform list of columns with return value with function which needs the actual columnName in Dataflow</title>
    <link>https://community.fabric.microsoft.com/t5/Dataflow/List-Transform-list-of-columns-with-return-value-with-function/m-p/3372605#M628</link>
    <description>&lt;P&gt;Hey!&lt;/P&gt;
&lt;P&gt;Is there any way that you can share a functional example M code that contains that list and what you're trying to achieve? wondering how your list actually looks like&lt;/P&gt;</description>
    <pubDate>Wed, 09 Aug 2023 16:17:24 GMT</pubDate>
    <dc:creator>miguel</dc:creator>
    <dc:date>2023-08-09T16:17:24Z</dc:date>
    <item>
      <title>List.Transform list of columns with return value with function which needs the actual columnName</title>
      <link>https://community.fabric.microsoft.com/t5/Dataflow/List-Transform-list-of-columns-with-return-value-with-function/m-p/3372525#M626</link>
      <description>&lt;P&gt;I am trying for a while to have a dynamic step to transform the data from 1-n columns with the result of a function call.&lt;/P&gt;&lt;P&gt;We are working on Dynamics 365 where we have a lot of optionsets.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a table with all optionsets and a step where I join my columnnames to this table. So I know which columns contain an optionset value.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;I have created a function which delivers the right label for the optionset value.&lt;/P&gt;&lt;P&gt;OptionLookup(&lt;EM&gt;opstionsetvalue,&lt;/EM&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;"&lt;EM&gt;entityname"&lt;/EM&gt;, "&lt;EM&gt;optionsetname(columnname)&lt;/EM&gt;")&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So basically I created a step:&lt;/P&gt;&lt;P&gt;Table.TransformColumns(DateToLocal,List.Transform(OptionsetColumns,&lt;/P&gt;&lt;P&gt;each {&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;EM&gt;, each OptionLookup(&lt;/EM&gt;, "bookableresource", "&lt;EM&gt;here should the columnName be as text&lt;/EM&gt;"), type text}))&lt;/P&gt;&lt;P&gt;the _ provides the right current value needed for the function, the function is also applied to the right columns but the function needs the ColumnName in text and I don't know how to get this.&lt;/P&gt;&lt;P&gt;I tried OptionsetColumns but then the whole list is inserted there.&lt;/P&gt;</description>
      <pubDate>Wed, 09 Aug 2023 15:30:12 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Dataflow/List-Transform-list-of-columns-with-return-value-with-function/m-p/3372525#M626</guid>
      <dc:creator>mrc_bob</dc:creator>
      <dc:date>2023-08-09T15:30:12Z</dc:date>
    </item>
    <item>
      <title>Re: List.Transform list of columns with return value with function which needs the actual columnName</title>
      <link>https://community.fabric.microsoft.com/t5/Dataflow/List-Transform-list-of-columns-with-return-value-with-function/m-p/3372605#M628</link>
      <description>&lt;P&gt;Hey!&lt;/P&gt;
&lt;P&gt;Is there any way that you can share a functional example M code that contains that list and what you're trying to achieve? wondering how your list actually looks like&lt;/P&gt;</description>
      <pubDate>Wed, 09 Aug 2023 16:17:24 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Dataflow/List-Transform-list-of-columns-with-return-value-with-function/m-p/3372605#M628</guid>
      <dc:creator>miguel</dc:creator>
      <dc:date>2023-08-09T16:17:24Z</dc:date>
    </item>
    <item>
      <title>Re: List.Transform list of columns with return value with function which needs the actual columnName</title>
      <link>https://community.fabric.microsoft.com/t5/Dataflow/List-Transform-list-of-columns-with-return-value-with-function/m-p/3372624#M629</link>
      <description>&lt;P&gt;Hi,&lt;BR /&gt;&lt;BR /&gt;I will give some guesses, I hope it provides some ideas to you, sorry in advance if it's a complete miss.&lt;BR /&gt;&lt;BR /&gt;You are trying, inside two level of "each" in power query, to retrieve metadata from the collection, in this case, the columnname. If Power Query had the function NameOf() maybe this would be perfect for what you want, but I think it hasn't yet, it's only in DAX.&lt;BR /&gt;&lt;BR /&gt;Did you thought about turn this logic upside down ? The Table.ColumnNames can retrieve the name of the columns, maybe you could loop through it to retrieve the value of the columns for each row, already having the columnnames in hand?&lt;BR /&gt;&lt;BR /&gt;Kind Regards,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Dennes&lt;/P&gt;</description>
      <pubDate>Wed, 09 Aug 2023 16:24:47 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Dataflow/List-Transform-list-of-columns-with-return-value-with-function/m-p/3372624#M629</guid>
      <dc:creator>DennesTorres</dc:creator>
      <dc:date>2023-08-09T16:24:47Z</dc:date>
    </item>
    <item>
      <title>Re: List.Transform list of columns with return value with function which needs the actual columnName</title>
      <link>https://community.fabric.microsoft.com/t5/Dataflow/List-Transform-list-of-columns-with-return-value-with-function/m-p/3372633#M630</link>
      <description>&lt;P&gt;I have one step with Table.ColumnNames which contains f.e. 3 columnsNames resourcetype, msdyn_startlocation,usertype.&lt;BR /&gt;This step is called OptionsetColumns and used in the List.Transform.&amp;nbsp;&lt;BR /&gt;the each _ gives the value of the column f.e.669010000.&amp;nbsp;&lt;BR /&gt;which I need as well the provide as the 1st parameter to the function but need the columns name like resourcetype as well.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I will post some more details later. Now on my phone....&lt;/P&gt;</description>
      <pubDate>Wed, 09 Aug 2023 16:31:48 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Dataflow/List-Transform-list-of-columns-with-return-value-with-function/m-p/3372633#M630</guid>
      <dc:creator>mrc_bob</dc:creator>
      <dc:date>2023-08-09T16:31:48Z</dc:date>
    </item>
    <item>
      <title>Re: List.Transform list of columns with return value with function which needs the actual columnName</title>
      <link>https://community.fabric.microsoft.com/t5/Dataflow/List-Transform-list-of-columns-with-return-value-with-function/m-p/3372661#M631</link>
      <description>&lt;P&gt;Hi,&lt;BR /&gt;&lt;BR /&gt;So, once again, I may be able to provide some guesses and hope they help:&lt;BR /&gt;&lt;BR /&gt;If OptionsetColumns is already an array of columnNames, such as&amp;nbsp;{"CustomerID", "Name", "Phone"},&lt;BR /&gt;the "_" on the first each, the 2n parameter of the List.Transform, is exactly the column name you want to retrieve.&lt;BR /&gt;&lt;BR /&gt;For example, just to have a better view of the code, let me show a silly example:&lt;BR /&gt;&lt;BR /&gt;List.Transform({"CustomerID", "Name", "Phone"}, each _ + "column")&lt;BR /&gt;&lt;BR /&gt;May result in&amp;nbsp;{"CustomerIDcolumn", "Namecolumn", "Phonecolumn"},&lt;BR /&gt;&lt;BR /&gt;But instead of the array you have OptionsetColumns, but it's the same. The "_" on the first each has the column name and in this case I don't fully understand how your 2nd each is working...&lt;BR /&gt;&lt;BR /&gt;Kind Regards,&lt;BR /&gt;&lt;BR /&gt;Dennes&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 09 Aug 2023 16:47:21 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Dataflow/List-Transform-list-of-columns-with-return-value-with-function/m-p/3372661#M631</guid>
      <dc:creator>DennesTorres</dc:creator>
      <dc:date>2023-08-09T16:47:21Z</dc:date>
    </item>
    <item>
      <title>Re: List.Transform list of columns with return value with function which needs the actual columnName</title>
      <link>https://community.fabric.microsoft.com/t5/Dataflow/List-Transform-list-of-columns-with-return-value-with-function/m-p/3372928#M635</link>
      <description>&lt;P&gt;So for this first each I had the idea already this is the column name.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;within my function I need the value of the record within that column, "static entity name", "column name"&lt;/P&gt;&lt;P&gt;I beleave the second each gives me the value correct. But how do I get the column name of the first each again?&lt;/P&gt;</description>
      <pubDate>Wed, 09 Aug 2023 20:23:18 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Dataflow/List-Transform-list-of-columns-with-return-value-with-function/m-p/3372928#M635</guid>
      <dc:creator>mrc_bob</dc:creator>
      <dc:date>2023-08-09T20:23:18Z</dc:date>
    </item>
    <item>
      <title>Re: List.Transform list of columns with return value with function which needs the actual columnName</title>
      <link>https://community.fabric.microsoft.com/t5/Dataflow/List-Transform-list-of-columns-with-return-value-with-function/m-p/3372933#M636</link>
      <description>&lt;P&gt;Hi,&lt;BR /&gt;&lt;BR /&gt;Sorry, I didn't get your 2nd each.&lt;BR /&gt;&lt;BR /&gt;The first each is inside the List.Transform. The List.Transform is applied over a single dimension array. The "_" is a string, the column name from the single dimension array.&lt;BR /&gt;&lt;BR /&gt;I didn't get what iteration the 2nd each is trying to do. What the "_" on the 2nd each is ? Does the 2nd each works, if you make a more simple transformation, without the function call ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Kind Regards,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Dennes&lt;/P&gt;</description>
      <pubDate>Wed, 09 Aug 2023 20:33:04 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Dataflow/List-Transform-list-of-columns-with-return-value-with-function/m-p/3372933#M636</guid>
      <dc:creator>DennesTorres</dc:creator>
      <dc:date>2023-08-09T20:33:04Z</dc:date>
    </item>
    <item>
      <title>Re: List.Transform list of columns with return value with function which needs the actual columnName</title>
      <link>https://community.fabric.microsoft.com/t5/Dataflow/List-Transform-list-of-columns-with-return-value-with-function/m-p/3373615#M637</link>
      <description>&lt;P&gt;So my Complete code for one source:&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;let&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; Bron = Sql.Database(&lt;/SPAN&gt;&lt;SPAN&gt;"synapse-365-ondemand.sql.azuresynapse.net"&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;"dataverse_**********"&lt;/SPAN&gt;&lt;SPAN&gt;),&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; DB = Value.NativeQuery(Bron,&lt;/SPAN&gt;&lt;SPAN&gt;"select bookableresourceid,createdon,modifiedon,createdbyname,modifiedbyname,owninguser,name,calendarid,contactid,resourcetype,statecode,statuscode,userid,contactidname,useridname,msdyn_organizationalunit,msdyn_startlocation,msdyn_targetutilization,msdyn_organizationalunitname,msdyn_facilityequipmentidname,msdyn_hourlyrate from bookableresource"&lt;/SPAN&gt;&lt;SPAN&gt; , &lt;/SPAN&gt;&lt;SPAN&gt;null&lt;/SPAN&gt;&lt;SPAN&gt;, [EnableFolding=&lt;/SPAN&gt;&lt;SPAN&gt;true&lt;/SPAN&gt;&lt;SPAN&gt;]),&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &lt;STRONG&gt;DateToLocal&lt;/STRONG&gt; = Table.TransformColumns(DB, List.Transform(Table.ColumnsOfType(DB,{&lt;/SPAN&gt;&lt;SPAN&gt;type&lt;/SPAN&gt;&lt;SPAN&gt; nullable &lt;/SPAN&gt;&lt;SPAN&gt;datetime&lt;/SPAN&gt;&lt;SPAN&gt;}),&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;each&lt;/SPAN&gt;&lt;SPAN&gt; { _, &lt;/SPAN&gt;&lt;SPAN&gt;each&lt;/SPAN&gt; &lt;SPAN&gt;if&lt;/SPAN&gt;&lt;SPAN&gt; _ = &lt;/SPAN&gt;&lt;SPAN&gt;null&lt;/SPAN&gt; &lt;SPAN&gt;then&lt;/SPAN&gt; &lt;SPAN&gt;null&lt;/SPAN&gt; &lt;SPAN&gt;else&lt;/SPAN&gt;&lt;SPAN&gt; f_DateToLocal(_)})),&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; OptionsetColumns = Table.ToList(Table.RemoveColumns(Table.NestedJoin(Table.FromList(Table.ColumnNames(DateToLocal),&lt;/SPAN&gt;&lt;SPAN&gt;null&lt;/SPAN&gt;&lt;SPAN&gt;,{&lt;/SPAN&gt;&lt;SPAN&gt;"ColumnName"&lt;/SPAN&gt;&lt;SPAN&gt;}), {&lt;/SPAN&gt;&lt;SPAN&gt;"ColumnName"&lt;/SPAN&gt;&lt;SPAN&gt;}, #"Optionsets (list)", {&lt;/SPAN&gt;&lt;SPAN&gt;"OptionSetName"&lt;/SPAN&gt;&lt;SPAN&gt;}, &lt;/SPAN&gt;&lt;SPAN&gt;"Optionsets (list)"&lt;/SPAN&gt;&lt;SPAN&gt;, JoinKind.Inner), {&lt;/SPAN&gt;&lt;SPAN&gt;"Optionsets (list)"&lt;/SPAN&gt;&lt;SPAN&gt;})),&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &lt;STRONG&gt;OptionsetLabels&lt;/STRONG&gt; = Table.TransformColumns(DateToLocal,List.Transform(OptionsetColumns,&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;each&lt;/SPAN&gt;&lt;SPAN&gt;{_, &lt;/SPAN&gt;&lt;SPAN&gt;each&lt;/SPAN&gt;&lt;SPAN&gt; OptionLookup(_, &lt;/SPAN&gt;&lt;SPAN&gt;"bookableresource"&lt;/SPAN&gt;&lt;SPAN&gt;, _) , &lt;/SPAN&gt;&lt;SPAN&gt;type&lt;/SPAN&gt; &lt;SPAN&gt;text&lt;/SPAN&gt;&lt;SPAN&gt;}))&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;in&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; OptionsetLabels&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;STRONG&gt;DateToLocal&lt;/STRONG&gt; is doing more or less the same: replace the existing value with a new value based on the FunctionOutcome, but here I don't need the columnName to be passes to the function.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;The list OptionSetColumns is:&lt;BR /&gt;&lt;img /&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;These columns have integers as values:&lt;/P&gt;&lt;img /&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So for each of these records the step:&amp;nbsp;&lt;SPAN&gt;&lt;STRONG&gt;OptionsetLabels&lt;/STRONG&gt; should replace the integer with a text label.&lt;/SPAN&gt;&lt;/P&gt;&lt;DIV&gt;&lt;SPAN&gt;Table.TransformColumns(DateToLocal,List.Transform(OptionsetColumns,&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;each&lt;/SPAN&gt;&lt;SPAN&gt;{_, &lt;/SPAN&gt;&lt;SPAN&gt;each&lt;/SPAN&gt;&lt;SPAN&gt; OptionLookup(&lt;STRONG&gt;690970000&lt;/STRONG&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;"bookableresource"&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;STRONG&gt;"msdyn_startlocation"&lt;/STRONG&gt;) , &lt;/SPAN&gt;&lt;SPAN&gt;type&lt;/SPAN&gt; &lt;SPAN&gt;text&lt;/SPAN&gt;&lt;SPAN&gt;})) works well for this but with the syntax:&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Table.TransformColumns(DateToLocal,List.Transform(OptionsetColumns,&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;each&lt;/SPAN&gt;&lt;SPAN&gt;{_, &lt;/SPAN&gt;&lt;SPAN&gt;each&lt;/SPAN&gt;&lt;SPAN&gt; OptionLookup(_, &lt;/SPAN&gt;&lt;SPAN&gt;"bookableresource"&lt;/SPAN&gt;&lt;SPAN&gt;, _) , &lt;/SPAN&gt;&lt;SPAN&gt;type&lt;/SPAN&gt; &lt;SPAN&gt;text&lt;/SPAN&gt;&lt;SPAN&gt;&lt;SPAN&gt;})) it does&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;DIV&gt;&lt;SPAN&gt;Table.TransformColumns(DateToLocal,List.Transform(OptionsetColumns,&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;each&lt;/SPAN&gt;&lt;SPAN&gt;{_, &lt;/SPAN&gt;&lt;SPAN&gt;each&lt;/SPAN&gt;&lt;SPAN&gt; OptionLookup(&lt;STRONG&gt;690970000&lt;/STRONG&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;"bookableresource"&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;690970000&lt;/STRONG&gt;&lt;/FONT&gt;) , &lt;/SPAN&gt;&lt;SPAN&gt;type&lt;/SPAN&gt; &lt;SPAN&gt;text&lt;/SPAN&gt;&lt;SPAN&gt;}))&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;When I set OptionsetColumns again it passes the list again, so I should get the &lt;STRONG&gt;_&lt;/STRONG&gt; of the &lt;STRONG&gt;first each&lt;/STRONG&gt; again I assume.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;I hope this makes sense.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Thanks for the help already.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Thu, 10 Aug 2023 07:48:54 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Dataflow/List-Transform-list-of-columns-with-return-value-with-function/m-p/3373615#M637</guid>
      <dc:creator>mrc_bob</dc:creator>
      <dc:date>2023-08-10T07:48:54Z</dc:date>
    </item>
    <item>
      <title>Re: List.Transform list of columns with return value with function which needs the actual columnName</title>
      <link>https://community.fabric.microsoft.com/t5/Dataflow/List-Transform-list-of-columns-with-return-value-with-function/m-p/3374668#M640</link>
      <description>&lt;P&gt;It's a bit convoluted for me to provide any actionable suggestions as I'm not entirely sure how the data looks like or if perhaps the data being accessed is correct or not. If you could make it more generic, with some simple lists created with pure M code at a more fundamental level, that would help us tackle this a bit better.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;However, if what you're trying to find out is more in line with how you can access a nested value in a way beyond the "each _" or how the "each _" works then I highly recommend the video below. I recorded this a few years back, but its still true to this day:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://www.youtube.com/watch?v=omu-sjzNO44" target="_blank"&gt;Adding Columns to Nested Table for Data Consolidation - YouTube&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 10 Aug 2023 16:21:32 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Dataflow/List-Transform-list-of-columns-with-return-value-with-function/m-p/3374668#M640</guid>
      <dc:creator>miguel</dc:creator>
      <dc:date>2023-08-10T16:21:32Z</dc:date>
    </item>
  </channel>
</rss>

