<?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 use a SELECTEDVALUE as column name in a Measure in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-use-a-SELECTEDVALUE-as-column-name-in-a-Measure/m-p/3167680#M114047</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="460868" data-lia-user-login="FreemanZ" class="lia-mention lia-mention-user"&gt;FreemanZ&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;appologies for not being very clear.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have made a fact table holding the column names to be analysed. When a column is selected, a measure builds the column name&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;EM&gt;SelectedColumn&lt;/EM&gt; =&amp;nbsp; "'Data Products'[" &amp;amp;&amp;nbsp;&amp;nbsp;SELECTEDVALUE(selected&amp;nbsp; column) &amp;amp; "]"&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I want to be able to use the value of this measure as the column reference, for example&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Avg = AVERAGE(&lt;EM&gt;SelectedColumn&lt;/EM&gt;)&lt;/STRONG&gt;&lt;/P&gt;</description>
    <pubDate>Sun, 02 Apr 2023 11:33:38 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2023-04-02T11:33:38Z</dc:date>
    <item>
      <title>How to use a SELECTEDVALUE as column name in a Measure</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-use-a-SELECTEDVALUE-as-column-name-in-a-Measure/m-p/3164122#M113726</link>
      <description>&lt;P&gt;I have a table with multiple numerical columns. I need to apply a set of measures such as Mean, Median, Mode, etc. of a selected column. The results are to be shown in a table. The goal is to build a data profiler.&lt;/P&gt;&lt;P&gt;EXAMPLE&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Data: Products&lt;/P&gt;&lt;P&gt;Product | Name Length | Description Length |&amp;nbsp; Country&lt;/P&gt;&lt;P&gt;A123&amp;nbsp; &amp;nbsp; &amp;nbsp; |&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;25&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; |&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;75&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; |&amp;nbsp; &amp;nbsp; UK&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;B321&amp;nbsp; &amp;nbsp; &amp;nbsp; |&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;15&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; |&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 88&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;|&amp;nbsp; &amp;nbsp; &amp;nbsp;FR&lt;/P&gt;&lt;P&gt;etc..&lt;/P&gt;&lt;P&gt;Measure:&lt;/P&gt;&lt;P&gt;Avg = AVERAGE(SELECTEDVALUE(selected&amp;nbsp; column))&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance for your assistance &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 30 Mar 2023 18:39:54 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-use-a-SELECTEDVALUE-as-column-name-in-a-Measure/m-p/3164122#M113726</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2023-03-30T18:39:54Z</dc:date>
    </item>
    <item>
      <title>Re: How to use a SELECTEDVALUE as column name in a Measure</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-use-a-SELECTEDVALUE-as-column-name-in-a-Measure/m-p/3164536#M113753</link>
      <description>&lt;P&gt;hi&amp;nbsp;Anonymous&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;SELECTEDVALUE returns a single value, while AVERAGE expects a column as its argument.&lt;/P&gt;&lt;P&gt;The point is it doesn't make sense to average oneself.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;SELECTEDVALUE is used more often to capture a slicer selection and use the captured value to filter a table/column.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 31 Mar 2023 01:21:48 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-use-a-SELECTEDVALUE-as-column-name-in-a-Measure/m-p/3164536#M113753</guid>
      <dc:creator>FreemanZ</dc:creator>
      <dc:date>2023-03-31T01:21:48Z</dc:date>
    </item>
    <item>
      <title>Re: How to use a SELECTEDVALUE as column name in a Measure</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-use-a-SELECTEDVALUE-as-column-name-in-a-Measure/m-p/3167680#M114047</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="460868" data-lia-user-login="FreemanZ" class="lia-mention lia-mention-user"&gt;FreemanZ&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;appologies for not being very clear.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have made a fact table holding the column names to be analysed. When a column is selected, a measure builds the column name&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;EM&gt;SelectedColumn&lt;/EM&gt; =&amp;nbsp; "'Data Products'[" &amp;amp;&amp;nbsp;&amp;nbsp;SELECTEDVALUE(selected&amp;nbsp; column) &amp;amp; "]"&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I want to be able to use the value of this measure as the column reference, for example&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Avg = AVERAGE(&lt;EM&gt;SelectedColumn&lt;/EM&gt;)&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 02 Apr 2023 11:33:38 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-use-a-SELECTEDVALUE-as-column-name-in-a-Measure/m-p/3167680#M114047</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2023-04-02T11:33:38Z</dc:date>
    </item>
    <item>
      <title>Re: How to use a SELECTEDVALUE as column name in a Measure</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-use-a-SELECTEDVALUE-as-column-name-in-a-Measure/m-p/3167727#M114052</link>
      <description>&lt;P&gt;hi&amp;nbsp;Anonymous&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The point is to unpivot your table first.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;supposing your table looks like:&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Product&lt;/TD&gt;&lt;TD&gt;Len1&lt;/TD&gt;&lt;TD&gt;Len2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;A1&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;10&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;A2&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;10&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;A3&lt;/TD&gt;&lt;TD&gt;4&lt;/TD&gt;&lt;TD&gt;40&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;try to unpivot it to:&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;then everything become intuitive with Power BI:&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;regarding unpivot:&lt;/P&gt;&lt;P&gt;the M code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WcjRU0lECYwOlWB0g3wiNbwxkm4AwkB8LAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Product = _t, Len1 = _t, Len2 = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Product", type text}, {"Len1", Int64.Type}, {"Len2", Int64.Type}}),
    #"Unpivoted Other Columns" = Table.UnpivotOtherColumns(#"Changed Type", {"Product"}, "Attribute", "Value"),
    #"Renamed Columns" = Table.RenameColumns(#"Unpivoted Other Columns",{{"Attribute", "Len"}})
in
    #"Renamed Columns"&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;or you do it following:&lt;/P&gt;&lt;P&gt;&lt;A href="https://monocroft.com/how-to-unpivot-columns-to-rows-in-powerbi/" target="_blank" rel="noopener"&gt;https://monocroft.com/how-to-unpivot-columns-to-rows-in-powerbi/&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 02 Apr 2023 12:16:10 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-use-a-SELECTEDVALUE-as-column-name-in-a-Measure/m-p/3167727#M114052</guid>
      <dc:creator>FreemanZ</dc:creator>
      <dc:date>2023-04-02T12:16:10Z</dc:date>
    </item>
    <item>
      <title>Re: How to use a SELECTEDVALUE as column name in a Measure</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-use-a-SELECTEDVALUE-as-column-name-in-a-Measure/m-p/3167744#M114057</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="460868" data-lia-user-login="FreemanZ" class="lia-mention lia-mention-user"&gt;FreemanZ&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;table in question has 2 million rows and 18 columns, was hoping there was a DAX alternative to Excels INDIRECT function.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This works and as you said the rest solves itself.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for your help.&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":thumbs_up:"&gt;👍&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 02 Apr 2023 12:52:13 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-use-a-SELECTEDVALUE-as-column-name-in-a-Measure/m-p/3167744#M114057</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2023-04-02T12:52:13Z</dc:date>
    </item>
  </channel>
</rss>

