<?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: Count Rows Based on Disconnected Tables in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Count-Rows-Based-on-Disconnected-Tables/m-p/1180092#M18368</link>
    <description>&lt;P&gt;Change the semicolons to pipe "|" and attack your enumerations with the PATH functions.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Does it really matter if you match to country or region?&amp;nbsp; If the combined list of countries and regions is unique (ie no two countries have the same region etc)&amp;nbsp; then you could combine you Mapping columns&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And lastly, use SWITCH() to exit the search after the first hit.&lt;/P&gt;</description>
    <pubDate>Wed, 24 Jun 2020 17:22:26 GMT</pubDate>
    <dc:creator>lbendlin</dc:creator>
    <dc:date>2020-06-24T17:22:26Z</dc:date>
    <item>
      <title>Count Rows Based on Disconnected Tables</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Count-Rows-Based-on-Disconnected-Tables/m-p/1179916#M18365</link>
      <description>&lt;P&gt;I have a 'Mapping' table with the following columns: &lt;STRONG&gt;Mapping[Country]&lt;/STRONG&gt; and &lt;STRONG&gt;Mapping[Region]&lt;/STRONG&gt;.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a second table 'Articles' that has two columns: &lt;STRONG&gt;Article[ID]&lt;/STRONG&gt; and &lt;STRONG&gt;Article[Geography_Tags]&lt;/STRONG&gt;. The Article[Geography_Tags] field contains a list of countries and/or regions that were tagged for that article (separated by semicolons). For example, the below are some values in this column:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;EM&gt;United States;China&lt;/EM&gt;&lt;/LI&gt;&lt;LI&gt;&lt;EM&gt;United States;North America;Asia;United Kingdom&lt;/EM&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;Because there is no common key between the Mapping[Country] and Article[Geography_Tags] columns, there is not a relationship between the two tables.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;On the table visual, I have a list of selected Mapping[Country]. For each selected Mapping[Country], I'd like to calculate the number of Articles for which that country (or country's region) was tagged.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Based on the above italicized values in the Articles[Geography_Tags] column, I would expect the following results:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;United States: 2 (notice that for the second entry above, United States get credit for the second entry only one time even though the country and region were both tagged)&lt;/LI&gt;&lt;LI&gt;North American countries other than United States: 1&lt;/LI&gt;&lt;LI&gt;China: 2 (because China is part of Asia, it would get credit for both articles)&lt;/LI&gt;&lt;LI&gt;Asian countries other than China: 1&lt;/LI&gt;&lt;LI&gt;United Kingdom: 1&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;Since the calculation depends on the filter context of Mapping[Country], I assume this should be a measure, but after that I'm a little stuck. Any and all help is greatly appreciated!&lt;/P&gt;</description>
      <pubDate>Wed, 24 Jun 2020 16:19:34 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Count-Rows-Based-on-Disconnected-Tables/m-p/1179916#M18365</guid>
      <dc:creator>msmays5</dc:creator>
      <dc:date>2020-06-24T16:19:34Z</dc:date>
    </item>
    <item>
      <title>Re: Count Rows Based on Disconnected Tables</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Count-Rows-Based-on-Disconnected-Tables/m-p/1180092#M18368</link>
      <description>&lt;P&gt;Change the semicolons to pipe "|" and attack your enumerations with the PATH functions.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Does it really matter if you match to country or region?&amp;nbsp; If the combined list of countries and regions is unique (ie no two countries have the same region etc)&amp;nbsp; then you could combine you Mapping columns&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And lastly, use SWITCH() to exit the search after the first hit.&lt;/P&gt;</description>
      <pubDate>Wed, 24 Jun 2020 17:22:26 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Count-Rows-Based-on-Disconnected-Tables/m-p/1180092#M18368</guid>
      <dc:creator>lbendlin</dc:creator>
      <dc:date>2020-06-24T17:22:26Z</dc:date>
    </item>
    <item>
      <title>Re: Count Rows Based on Disconnected Tables</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Count-Rows-Based-on-Disconnected-Tables/m-p/1180138#M18370</link>
      <description>&lt;P&gt;Thanks for the response,&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="100342" data-lia-user-login="lbendlin" class="lia-mention lia-mention-user"&gt;lbendlin&lt;/a&gt;. There are multiple countries that have the same Region (the list of two items I included in my example was just a short list). I have a list of 95 countries, each of which belongs to a single region.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Because a value in Article[Geography_Tags] could contain the country, the region, or both, my thought was to filter the Article table to include only rows where Article[Geography_Tags] contains either the selected Mapping[Country] or the country's Mapping[Region]. But I think that's where I'm getting hung up&lt;/P&gt;</description>
      <pubDate>Wed, 24 Jun 2020 17:37:48 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Count-Rows-Based-on-Disconnected-Tables/m-p/1180138#M18370</guid>
      <dc:creator>msmays5</dc:creator>
      <dc:date>2020-06-24T17:37:48Z</dc:date>
    </item>
    <item>
      <title>Re: Count Rows Based on Disconnected Tables</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Count-Rows-Based-on-Disconnected-Tables/m-p/1180155#M18371</link>
      <description>&lt;P&gt;here's another crazy idea approach&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;add a semicolon to the front and the back of your enumeration.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;for example instead of&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;United States;Asia&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;this would be&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;;United States;Asia;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;That helps to prevent bleedover.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Next, use DAX FIND() or SEARCH() functions with that string against your Mapping columns, First against the Country column and then (if nothing found) against the region column&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 24 Jun 2020 17:43:43 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Count-Rows-Based-on-Disconnected-Tables/m-p/1180155#M18371</guid>
      <dc:creator>lbendlin</dc:creator>
      <dc:date>2020-06-24T17:43:43Z</dc:date>
    </item>
    <item>
      <title>Re: Count Rows Based on Disconnected Tables</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Count-Rows-Based-on-Disconnected-Tables/m-p/1180336#M18380</link>
      <description>&lt;P&gt;Thanks,&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="100342" data-lia-user-login="lbendlin" class="lia-mention lia-mention-user"&gt;lbendlin&lt;/a&gt;. In PowerQuery, I prepended a semicolon. I then created the below measure, which works. However, I have one final question.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In addition to showing the below value where the visual provides a filter context to a single market, I'd also like to have a card that will show the maximum value for any of the selected markets. Put another way, if a user selects China and United States, the card would compute the below for both United States and China, and then take the maximum of that value.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How can I modify the below to work with an iterator (which is what I think I need?)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;VAR _country =
    SELECTEDVALUE ( Mapping[Country], "Multi" )
VAR _countrySemiColon = 
    IF ( _country &amp;lt;&amp;gt; "Multi", CONCATENATE(";", _country), "Multi" )
VAR _region =
    IF (
        _country &amp;lt;&amp;gt; "Multi",
        LOOKUPVALUE (Mapping[Region], Mapping[Country], _country),
        "Unknown"
    )
VAR _regionSemiColon = IF ( _country &amp;lt;&amp;gt; "Multi", CONCATENATE(";", _region), "Unknown" )
RETURN
    IF (
        _country &amp;lt;&amp;gt; "Multi",
        COUNTROWS (
            FILTER (
                Article,
                SEARCH ( _countrySemiColon, Article[Geography_Tags],, 0 ) &amp;lt;&amp;gt; 0
                    || SEARCH ( _regionSemiColon, Article[Geography_Tags],, 0 ) &amp;lt;&amp;gt; 0
            )
        ),
        "Multiple Countries are selected"
    )&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 24 Jun 2020 20:12:21 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Count-Rows-Based-on-Disconnected-Tables/m-p/1180336#M18380</guid>
      <dc:creator>msmays5</dc:creator>
      <dc:date>2020-06-24T20:12:21Z</dc:date>
    </item>
    <item>
      <title>Re: Count Rows Based on Disconnected Tables</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Count-Rows-Based-on-Disconnected-Tables/m-p/1183427#M18540</link>
      <description>&lt;P&gt;I was able to solve this. For anyone who comes across this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Count of Articles =
MAXX (
    Mapping,
    VAR _countrySemiColon =
        CONCATENATE ( ";", Mapping[Country ] )
    VAR _regionSemiColon =
        CONCATENATE ( ";", Mapping[Region Tag] )
    VAR _FilteredTable =
        FILTER (
            Articles,
            (
                SEARCH ( _countrySemiColon, Article[Geography_Tags],, 0 ) &amp;lt;&amp;gt; 0
                    || SEARCH ( _regionSemiColon, Article[Geography_Tags],, 0 ) &amp;lt;&amp;gt; 0
            )
        )
    RETURN
        COUNTROWS ( _FilteredTable )
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 25 Jun 2020 21:40:03 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Count-Rows-Based-on-Disconnected-Tables/m-p/1183427#M18540</guid>
      <dc:creator>msmays5</dc:creator>
      <dc:date>2020-06-25T21:40:03Z</dc:date>
    </item>
  </channel>
</rss>

