<?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, for 2 different keys, the number of shared values in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Count-for-2-different-keys-the-number-of-shared-values/m-p/963316#M11365</link>
    <description>&lt;P&gt;You have to have 2 tables with unique Stores only so that you can select 2 stores independently.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;"Store 1" Table:&lt;/P&gt;
&lt;P&gt;Key&lt;/P&gt;
&lt;P&gt;Store 1&lt;/P&gt;
&lt;P&gt;Store 2&lt;/P&gt;
&lt;P&gt;Store 3&lt;/P&gt;
&lt;P&gt;...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;"Store 2" Table:&lt;/P&gt;
&lt;P&gt;Key&lt;/P&gt;
&lt;P&gt;Store 1&lt;/P&gt;
&lt;P&gt;Store 2&lt;/P&gt;
&lt;P&gt;Store 3&lt;/P&gt;
&lt;P&gt;...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;These tables will not be connected to the table that holds Key and Values. If one store is selected from Store 1 and one is selected from Store 2, then here's a measure that will calculate the number of values they have in common:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;[# Values In Common] =
var __store1 = selectedvalue( 'Store 1'[Key] )
var __store2 = selectedvalue( 'Store 2'[Key] )
var __values1 =
	CALCULATETABLE(
		DISTINCT( StoresWithValues[Value] ),
		treatas( __store1, StoresWithValues[Key] )
	)
var __values2 =
	CALCULATETABLE(
		DISTINCT( StoresWithValues[Value] ),
		treatas( __store1, StoresWithValues[Key] )
	)
var __result =
	COUNTROWS(
		INTERSECT(
			__values1,
			__values2
		)
	)
return
	__result&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best&lt;/P&gt;
&lt;P&gt;D&lt;/P&gt;</description>
    <pubDate>Sat, 07 Mar 2020 22:49:31 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2020-03-07T22:49:31Z</dc:date>
    <item>
      <title>Count, for 2 different keys, the number of shared values</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Count-for-2-different-keys-the-number-of-shared-values/m-p/960562#M11213</link>
      <description>&lt;P&gt;hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a table like this :&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Key&lt;/TD&gt;&lt;TD&gt;Value&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Store 1&lt;/TD&gt;&lt;TD&gt;Apple&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Store 1&lt;/TD&gt;&lt;TD&gt;Orange&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Store 2&lt;/TD&gt;&lt;TD&gt;Apple&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Store 2&lt;/TD&gt;&lt;TD&gt;Banana&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Store 2&lt;/TD&gt;&lt;TD&gt;Orange&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Store 3&lt;/TD&gt;&lt;TD&gt;Banana&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Store 3&lt;/TD&gt;&lt;TD&gt;Orange&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would like to display a card where, when I select 2 stores, I get the number of values they have in common.&lt;/P&gt;&lt;P&gt;I tought of creating a table like that :&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;key 1&lt;/TD&gt;&lt;TD&gt;key 2&lt;/TD&gt;&lt;TD&gt;(Calculated column) Nb shared values&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Store 1&lt;/TD&gt;&lt;TD&gt;Store 2&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Store 1&lt;/TD&gt;&lt;TD&gt;Store 3&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Store 2&lt;/TD&gt;&lt;TD&gt;Store 1&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Store 2&lt;/TD&gt;&lt;TD&gt;Store 3&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Store 3&lt;/TD&gt;&lt;TD&gt;Store 1&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Store 3&lt;/TD&gt;&lt;TD&gt;Store 2&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;That way I can filter on key 1 and key 2 and display the Nb shared values.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is it the right way to do it ? If yes, how do I compute the "Nb shared values" column with DAX ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance for your help.&lt;/P&gt;</description>
      <pubDate>Thu, 05 Mar 2020 13:51:25 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Count-for-2-different-keys-the-number-of-shared-values/m-p/960562#M11213</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-03-05T13:51:25Z</dc:date>
    </item>
    <item>
      <title>Re: Count, for 2 different keys, the number of shared values</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Count-for-2-different-keys-the-number-of-shared-values/m-p/960571#M11214</link>
      <description>Perhaps my In Common quick measure: &lt;A href="https://community.powerbi.com/t5/Quick-Measures-Gallery/In-Common/m-p/382956#M117" target="_blank"&gt;https://community.powerbi.com/t5/Quick-Measures-Gallery/In-Common/m-p/382956#M117&lt;/A&gt;</description>
      <pubDate>Thu, 05 Mar 2020 13:55:35 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Count-for-2-different-keys-the-number-of-shared-values/m-p/960571#M11214</guid>
      <dc:creator>Greg_Deckler</dc:creator>
      <dc:date>2020-03-05T13:55:35Z</dc:date>
    </item>
    <item>
      <title>Re: Count, for 2 different keys, the number of shared values</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Count-for-2-different-keys-the-number-of-shared-values/m-p/960602#M11216</link>
      <description>&lt;P&gt;Hi Greg,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for your quick answer !&lt;/P&gt;&lt;P&gt;It looks like it coud be the solution &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; I will test it.&lt;/P&gt;&lt;P&gt;But can you please explain to us how did you construct your measure ? I don't get it ...&lt;/P&gt;&lt;PRE&gt;InCommon = 
VAR students1 = FILTER(ALL(Students),Students[Teacher]=MAX(Teachers[Teacher]))
VAR students1a = SELECTCOLUMNS(students1,"MyStudent",[Student])
VAR students2 = FILTER(ALL(Students),Students[Teacher]=MAX(Teachers2[Teacher]))
VAR students2a = SELECTCOLUMNS(students2,"MyStudent",[Student])
VAR incommon = COUNTROWS(INTERSECT(students1a,students2a))
RETURN IF(ISBLANK(incommon),0,incommon)&lt;/PRE&gt;</description>
      <pubDate>Thu, 05 Mar 2020 14:13:46 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Count-for-2-different-keys-the-number-of-shared-values/m-p/960602#M11216</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-03-05T14:13:46Z</dc:date>
    </item>
    <item>
      <title>Re: Count, for 2 different keys, the number of shared values</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Count-for-2-different-keys-the-number-of-shared-values/m-p/963316#M11365</link>
      <description>&lt;P&gt;You have to have 2 tables with unique Stores only so that you can select 2 stores independently.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;"Store 1" Table:&lt;/P&gt;
&lt;P&gt;Key&lt;/P&gt;
&lt;P&gt;Store 1&lt;/P&gt;
&lt;P&gt;Store 2&lt;/P&gt;
&lt;P&gt;Store 3&lt;/P&gt;
&lt;P&gt;...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;"Store 2" Table:&lt;/P&gt;
&lt;P&gt;Key&lt;/P&gt;
&lt;P&gt;Store 1&lt;/P&gt;
&lt;P&gt;Store 2&lt;/P&gt;
&lt;P&gt;Store 3&lt;/P&gt;
&lt;P&gt;...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;These tables will not be connected to the table that holds Key and Values. If one store is selected from Store 1 and one is selected from Store 2, then here's a measure that will calculate the number of values they have in common:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;[# Values In Common] =
var __store1 = selectedvalue( 'Store 1'[Key] )
var __store2 = selectedvalue( 'Store 2'[Key] )
var __values1 =
	CALCULATETABLE(
		DISTINCT( StoresWithValues[Value] ),
		treatas( __store1, StoresWithValues[Key] )
	)
var __values2 =
	CALCULATETABLE(
		DISTINCT( StoresWithValues[Value] ),
		treatas( __store1, StoresWithValues[Key] )
	)
var __result =
	COUNTROWS(
		INTERSECT(
			__values1,
			__values2
		)
	)
return
	__result&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best&lt;/P&gt;
&lt;P&gt;D&lt;/P&gt;</description>
      <pubDate>Sat, 07 Mar 2020 22:49:31 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Count-for-2-different-keys-the-number-of-shared-values/m-p/963316#M11365</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-03-07T22:49:31Z</dc:date>
    </item>
  </channel>
</rss>

