<?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 Calculated column based on multiple column in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculated-column-based-on-multiple-column/m-p/3156521#M113232</link>
    <description>&lt;P&gt;Hello All,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I could use some help regarding a DAX calculation.&lt;/P&gt;&lt;P&gt;I have multiple columns upto 100 which has value 'x' or null.&lt;/P&gt;&lt;P&gt;In case if the column contains 'x' value, I need to capture the name of the column in the calculated column.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It would have been simple if each row only had one column value, but for a row , multiple columns can have value 'x'.&lt;/P&gt;&lt;P&gt;In that case I need to capture all the columns which have value 'x'. (Eg: id 2 has values in col2 and col4)&amp;nbsp;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have attached a screenshot of my table.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 27 Mar 2023 15:44:19 GMT</pubDate>
    <dc:creator>abdul26</dc:creator>
    <dc:date>2023-03-27T15:44:19Z</dc:date>
    <item>
      <title>Calculated column based on multiple column</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculated-column-based-on-multiple-column/m-p/3156521#M113232</link>
      <description>&lt;P&gt;Hello All,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I could use some help regarding a DAX calculation.&lt;/P&gt;&lt;P&gt;I have multiple columns upto 100 which has value 'x' or null.&lt;/P&gt;&lt;P&gt;In case if the column contains 'x' value, I need to capture the name of the column in the calculated column.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It would have been simple if each row only had one column value, but for a row , multiple columns can have value 'x'.&lt;/P&gt;&lt;P&gt;In that case I need to capture all the columns which have value 'x'. (Eg: id 2 has values in col2 and col4)&amp;nbsp;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have attached a screenshot of my table.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 27 Mar 2023 15:44:19 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculated-column-based-on-multiple-column/m-p/3156521#M113232</guid>
      <dc:creator>abdul26</dc:creator>
      <dc:date>2023-03-27T15:44:19Z</dc:date>
    </item>
    <item>
      <title>Re: Calculated column based on multiple column</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculated-column-based-on-multiple-column/m-p/3156645#M113237</link>
      <description>&lt;P&gt;I am not aware of a way to do this in DAX. The DAX functions cannot return columns and other metadata like that. Power Query can though.&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&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("i45WMlTSUaoAYiiK1YlWMoKwK2AUSMwYrqQCpswERRlYyBRhEFhjLAA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [ID = _t, Col1 = _t, Col2 = _t, Col3 = _t, Col4 = _t]),
    #"Replaced Value" = Table.ReplaceValue(Source,"",null,Replacer.ReplaceValue,{"Col1", "Col2", "Col3", "Col4"}),
    #"Unpivoted Other Columns" = Table.UnpivotOtherColumns(#"Replaced Value", {"ID"}, "Attribute", "Value"),
    #"Grouped Rows" = Table.Group(#"Unpivoted Other Columns", {"ID"}, {{"All Rows", each _, type table [ID=number, Attribute=text, Value=text]}}),
    #"Added Has X" = Table.AddColumn(#"Grouped Rows", "Has X", each Text.Combine([All Rows][Attribute], ", ")),
    #"Merged Queries" = Table.NestedJoin(#"Replaced Value", {"ID"}, #"Added Has X", {"ID"}, "Added Has X", JoinKind.LeftOuter),
    #"Expanded Added Has X" = Table.ExpandTableColumn(#"Merged Queries", "Added Has X", {"Has X"}, {"Has X"})
in
    #"Expanded Added Has X"&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I did this by unpivoting data, then grouping it, then getting the colums that had an X.&lt;/P&gt;
&lt;P&gt;How to use M code provided in a blank query:&lt;BR /&gt;1) In Power Query, select New Source, then Blank Query&lt;BR /&gt;2) On the Home ribbon, select "Advanced Editor" button&lt;BR /&gt;3) Remove everything you see, then paste the M code I've given you in that box.&lt;BR /&gt;4) Press Done&lt;BR /&gt;5) &lt;A href="https://community.powerbi.com/t5/Community-Blog/Utilizing-M-Code-Samples-Given-as-Solutions-in-Power-Query/ba-p/1147514" target="_blank"&gt;See this article if you need help using this M code in your model.&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 27 Mar 2023 16:33:00 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculated-column-based-on-multiple-column/m-p/3156645#M113237</guid>
      <dc:creator>edhans</dc:creator>
      <dc:date>2023-03-27T16:33:00Z</dc:date>
    </item>
    <item>
      <title>Re: Calculated column based on multiple column</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculated-column-based-on-multiple-column/m-p/3156757#M113241</link>
      <description>&lt;P&gt;Thanks alot ! It helps a lot.&amp;nbsp;&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="24715" data-lia-user-login="edhans" class="lia-mention lia-mention-user"&gt;edhans&lt;/a&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 27 Mar 2023 17:31:47 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculated-column-based-on-multiple-column/m-p/3156757#M113241</guid>
      <dc:creator>abdul26</dc:creator>
      <dc:date>2023-03-27T17:31:47Z</dc:date>
    </item>
    <item>
      <title>Re: Calculated column based on multiple column</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculated-column-based-on-multiple-column/m-p/3158210#M113340</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="449447" data-lia-user-login="abdul26" class="lia-mention lia-mention-user"&gt;abdul26&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;For you and for other searchers who are looking for a DAX measure solution that does not require typing the names of the existing 100 columns, can refer to attached sample file with the solution.&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 28 Mar 2023 10:41:51 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculated-column-based-on-multiple-column/m-p/3158210#M113340</guid>
      <dc:creator>tamerj1</dc:creator>
      <dc:date>2023-03-28T10:41:51Z</dc:date>
    </item>
  </channel>
</rss>

