<?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: Measure that counts in second column in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Measure-that-counts-in-second-column/m-p/3970379#M153987</link>
    <description>&lt;P&gt;Hello lbendlin,&lt;BR /&gt;Thank you for your reply. I have omitted some (many) columns in the sample data. So the data is mutable. It could be that the persons are filtered e.g. by year of birth or by gender etc., in which case the number should still be calculated correctly. As I understand it, I can only do this with a measure, right?&lt;/P&gt;&lt;P&gt;Best regards&lt;/P&gt;&lt;P&gt;Michael&lt;/P&gt;</description>
    <pubDate>Tue, 04 Jun 2024 06:09:51 GMT</pubDate>
    <dc:creator>MichaelH78</dc:creator>
    <dc:date>2024-06-04T06:09:51Z</dc:date>
    <item>
      <title>Measure that counts in second column</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Measure-that-counts-in-second-column/m-p/3969628#M153962</link>
      <description>&lt;P&gt;Hi, I have a table with three columns:&lt;BR /&gt;- Person number&lt;BR /&gt;- Primary residence (city)&lt;BR /&gt;- Secondary residence (city)&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;STRONG&gt;Person number&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;Primary residence (city)&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;Secondary residence (city)&lt;/STRONG&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;City 1&lt;/TD&gt;&lt;TD&gt;City 2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;City 2&lt;/TD&gt;&lt;TD&gt;City 1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;City 1&lt;/TD&gt;&lt;TD&gt;City 3&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;4&lt;/TD&gt;&lt;TD&gt;City 1&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;5&lt;/TD&gt;&lt;TD&gt;City 3&lt;/TD&gt;&lt;TD&gt;City 1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;6&lt;/TD&gt;&lt;TD&gt;City 2&lt;/TD&gt;&lt;TD&gt;City 3&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now I am looking for a measure that determines the number of data records that have the city in their primary or secondary residence. The first column in the matrix visual (or in the Excel pivot table) contains a list of primary residence locations.&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;STRONG&gt;City&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;Count&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;Explanation&lt;/STRONG&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;City 1&lt;/TD&gt;&lt;TD&gt;5&lt;/TD&gt;&lt;TD&gt;3 times primary, 2 times secondary&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;City 2&lt;/TD&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;2 times primary, 1 time secondary&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;City 3&lt;/TD&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;1 time primary, 2 times secondary&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you&lt;BR /&gt;Michael&lt;/P&gt;</description>
      <pubDate>Mon, 03 Jun 2024 21:13:35 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Measure-that-counts-in-second-column/m-p/3969628#M153962</guid>
      <dc:creator>MichaelH78</dc:creator>
      <dc:date>2024-06-03T21:13:35Z</dc:date>
    </item>
    <item>
      <title>Re: Measure that counts in second column</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Measure-that-counts-in-second-column/m-p/3969744#M153969</link>
      <description>&lt;P&gt;Why should that be a measure?&amp;nbsp; Sounds like this data is immutable. So it can be done in Power Query.&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("i45WCkgtKs7PU8grzU1KLVLSUQooysxNLKpUKEotzkxJzUtOVdBIziyp1ARKBacm5+elYJWM1YlWMgQqcQbyFOAMI7C4EYILVwASN8ZQbwwWN0EWVwALmSJUoBhhhmE00IhYAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Column1 = _t, Column2 = _t, Column3 = _t]),
    #"Promoted Headers" = Table.PromoteHeaders(Source, [PromoteAllScalars=true]),
    #"Unpivoted Other Columns" = Table.UnpivotOtherColumns(#"Promoted Headers", {"Person number"}, "Attribute", "Value"),
    #"Grouped Rows" = Table.Group(#"Unpivoted Other Columns", {"Value"}, {{"Count", each Table.RowCount(_), Int64.Type}})
in
    #"Grouped Rows"&lt;/LI-CODE&gt;
&lt;P&gt;How to use this code: Create a new Blank Query. Click on "Advanced Editor". Replace the code in the window with the code provided here. Click "Done". Once you examined the code, replace the Source step with your own source.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 03 Jun 2024 22:52:53 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Measure-that-counts-in-second-column/m-p/3969744#M153969</guid>
      <dc:creator>lbendlin</dc:creator>
      <dc:date>2024-06-03T22:52:53Z</dc:date>
    </item>
    <item>
      <title>Re: Measure that counts in second column</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Measure-that-counts-in-second-column/m-p/3970379#M153987</link>
      <description>&lt;P&gt;Hello lbendlin,&lt;BR /&gt;Thank you for your reply. I have omitted some (many) columns in the sample data. So the data is mutable. It could be that the persons are filtered e.g. by year of birth or by gender etc., in which case the number should still be calculated correctly. As I understand it, I can only do this with a measure, right?&lt;/P&gt;&lt;P&gt;Best regards&lt;/P&gt;&lt;P&gt;Michael&lt;/P&gt;</description>
      <pubDate>Tue, 04 Jun 2024 06:09:51 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Measure-that-counts-in-second-column/m-p/3970379#M153987</guid>
      <dc:creator>MichaelH78</dc:creator>
      <dc:date>2024-06-04T06:09:51Z</dc:date>
    </item>
    <item>
      <title>Re: Measure that counts in second column</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Measure-that-counts-in-second-column/m-p/3970464#M153990</link>
      <description>&lt;P&gt;Hi &lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="684284" data-lia-user-login="MichaelH78" class="lia-mention lia-mention-user"&gt;MichaelH78&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;First of all, many thanks to&amp;nbsp; for your very quick and effective replies.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;Based on my testing, please &lt;SPAN&gt;try the following methods:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;1.Create the simple table.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;2.Create the new measure to calculate the number of city primary residence.&lt;/SPAN&gt;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Count primary city = 
var cit_ = SELECTEDVALUE('Table city'[City])
RETURN
COUNTROWS(FILTER('Table', 'Table'[Primary residence (city)] = cit_))&lt;/LI-CODE&gt;&lt;LI-CODE lang="markup"&gt;Count secondary city = 
var cit_ = SELECTEDVALUE('Table city'[City])
RETURN
COUNTROWS(FILTER('Table', 'Table'[Secondary residence (city)] = cit_))&lt;/LI-CODE&gt;
&lt;P&gt;&lt;SPAN&gt;3.Create the new measure to calculate the count.&lt;/SPAN&gt;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Count = [Count primary city] + [Count secondary city]&lt;/LI-CODE&gt;
&lt;P&gt;&lt;SPAN&gt;4.Drag the category field into the slicer.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;5.The result is shown below.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;/P&gt;
&lt;P&gt;Wisdom Wu&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;If this post&amp;nbsp;&lt;STRONG&gt;&lt;EM&gt;helps&lt;/EM&gt;&lt;/STRONG&gt;, then please consider&amp;nbsp;&lt;STRONG&gt;&lt;EM&gt;Accept it as the solution&lt;/EM&gt;&lt;/STRONG&gt;&amp;nbsp;to help the other members find it more quickly.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 04 Jun 2024 06:54:30 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Measure-that-counts-in-second-column/m-p/3970464#M153990</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-06-04T06:54:30Z</dc:date>
    </item>
    <item>
      <title>Re: Measure that counts in second column</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Measure-that-counts-in-second-column/m-p/3970611#M153999</link>
      <description>&lt;P&gt;Hi&amp;nbsp;Wisdom Wu,&lt;/P&gt;&lt;P&gt;hi, thanks for your help. This looks very good and also works in Power BI.&lt;BR /&gt;Before I transfer everything to Power BI: Does this also work in Excel? Power Pivot in Excel does not recognise SELECTEDVALUE. You can probably do something with HASONEVALUE, but I can't manage that &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Best regards&lt;/P&gt;&lt;P&gt;Michael&lt;/P&gt;</description>
      <pubDate>Tue, 04 Jun 2024 08:09:55 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Measure-that-counts-in-second-column/m-p/3970611#M153999</guid>
      <dc:creator>MichaelH78</dc:creator>
      <dc:date>2024-06-04T08:09:55Z</dc:date>
    </item>
    <item>
      <title>Re: Measure that counts in second column</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Measure-that-counts-in-second-column/m-p/3972383#M154039</link>
      <description>&lt;P&gt;I have solved it simply: With an additional column in data, which calculates the number per primary residence location, but in primary and secondary residence. This means that all rows with the same location always contain the same value.&lt;BR /&gt;The measure then only needs to add a MAX (or MIN or AVG) to the new column &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 04 Jun 2024 21:00:29 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Measure-that-counts-in-second-column/m-p/3972383#M154039</guid>
      <dc:creator>MichaelH78</dc:creator>
      <dc:date>2024-06-04T21:00:29Z</dc:date>
    </item>
  </channel>
</rss>

