<?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: Covariance in Quick Measures Gallery</title>
    <link>https://community.fabric.microsoft.com/t5/Quick-Measures-Gallery/Covariance/m-p/619805#M291</link>
    <description>&lt;P&gt;I think you are missing a closing paren, in red&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;Covariance = 
VAR AvgA = 
CALCULATE(
	AVERAGE('PeriodSummary-FLEXMUIRRebalancing'[Total Return]), 
	ALL('PeriodSummary-FLEXMUIRRebalancing')
)
VAR AvgB = 
CALCULATE(
	AVERAGE('PeriodSummary-FLEXMUIRRebalancing'[Benchmark Return]), 
	ALL('PeriodSummary-FLEXMUIRRebalancing')
)

VAR MyTable = 
SUMMARIZE(
	'PeriodSummary-FLEXMUIRRebalancing', 
	'PeriodSummary-FLEXMUIRRebalancing'[Total Return], 
	"PeriodSummary-FLEXMUIRRebalancing", 
	('PeriodSummary-FLEXMUIRRebalancing'[Total Return] - AvgA)
	*
	(MAX('PeriodSummary-FLEXMUIRRebalancing'[Benchmark Return]&lt;FONT face="arial black,avant garde"&gt;&lt;STRONG&gt;&lt;FONT color="#ff0000"&gt;)&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/FONT&gt; - AvgB) 
	/ 
	CALCULATE(
		COUNTROWS('PeriodSummary-FLEXMUIRRebalancing'), 
		ALL('PeriodSummary-FLEXMUIRRebalancing')
	)
)
RETURN &lt;/PRE&gt;</description>
    <pubDate>Sat, 09 Feb 2019 00:36:21 GMT</pubDate>
    <dc:creator>Greg_Deckler</dc:creator>
    <dc:date>2019-02-09T00:36:21Z</dc:date>
    <item>
      <title>Covariance</title>
      <link>https://community.fabric.microsoft.com/t5/Quick-Measures-Gallery/Covariance/m-p/379069#M115</link>
      <description>&lt;P&gt;&lt;SPAN&gt;From Wikipedia on Covariance:&amp;nbsp;&lt;A href="https://en.wikipedia.org/wiki/Covariance" target="_blank"&gt;https://en.wikipedia.org/wiki/Covariance&lt;/A&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;In &lt;/SPAN&gt;&lt;A title="Probability theory" href="https://en.wikipedia.org/wiki/Probability_theory" target="_blank"&gt;probability theory&lt;/A&gt;&lt;SPAN&gt; and &lt;/SPAN&gt;&lt;A title="Statistics" href="https://en.wikipedia.org/wiki/Statistics" target="_blank"&gt;statistics&lt;/A&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;STRONG&gt;covariance&lt;/STRONG&gt;&lt;SPAN&gt; is a measure of the joint variability of two &lt;/SPAN&gt;&lt;A title="Random variable" href="https://en.wikipedia.org/wiki/Random_variable" target="_blank"&gt;random variables&lt;/A&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SUP class="reference" id="cite_ref-1"&gt;&lt;A href="https://en.wikipedia.org/wiki/Covariance#cite_note-1" target="_blank"&gt;[1]&lt;/A&gt;&lt;/SUP&gt;&lt;SPAN&gt; If the greater values of one variable mainly correspond with the greater values of the other variable, and the same holds for the lesser values, i.e., the variables tend to show similar behavior, the covariance is positive.&lt;/SPAN&gt;&lt;SUP class="reference" id="cite_ref-2"&gt;&lt;A href="https://en.wikipedia.org/wiki/Covariance#cite_note-2" target="_blank"&gt;[2]&lt;/A&gt;&lt;/SUP&gt;&lt;SPAN&gt; In the opposite case, when the greater values of one variable mainly correspond to the lesser values of the other, i.e., the variables tend to show opposite behavior, the covariance is negative. The sign of the covariance therefore shows the tendency in the &lt;/SPAN&gt;&lt;A title="Linear relationship" class="mw-redirect" href="https://en.wikipedia.org/wiki/Linear_relationship" target="_blank"&gt;linear relationship&lt;/A&gt;&lt;SPAN&gt; between the variables. The magnitude of the covariance is not easy to interpret because it is not normalized and hence depends on the magnitudes of the variables. The &lt;/SPAN&gt;&lt;A title="Covariance and correlation" href="https://en.wikipedia.org/wiki/Covariance_and_correlation" target="_blank"&gt;normalized version of the covariance&lt;/A&gt;&lt;SPAN&gt;, the &lt;/SPAN&gt;&lt;A title="Pearson product-moment correlation coefficient" class="mw-redirect" href="https://en.wikipedia.org/wiki/Pearson_product-moment_correlation_coefficient" target="_blank"&gt;correlation coefficient&lt;/A&gt;&lt;SPAN&gt;, however, shows by its magnitude the strength of the linear relation.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;The covariance formula from&amp;nbsp;&lt;A href="http://mathworld.wolfram.com/Covariance.html" target="_blank"&gt;http://mathworld.wolfram.com/Covariance.html&lt;/A&gt; is the following:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;img /&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Thus, the following DAX measure equation performs this formula on a table (Covariance) with two columns (A and B).&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;Covariance = 
VAR AvgA = CALCULATE(AVERAGE('Covariance'[A]),ALL('Covariance'))
VAR AvgB = CALCULATE(AVERAGE('Covariance'[B]),ALL('Covariance'))
VAR MyTable = SUMMARIZE('Covariance','Covariance'[A],"Covariance",([A]-AvgA)*(MAX('Covariance'[B])-AvgB)/CALCULATE(COUNTROWS('Covariance'),ALL('Covariance')))
RETURN SUMX(MyTable,[Covariance])
&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&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;
&lt;P&gt;&amp;nbsp;&lt;/P&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;
&lt;P&gt;&lt;SPAN class="reportid hidden"&gt;eyJrIjoiOTU5MWM1M2QtZTdlMy00ZTY4LThkODgtZjU1YzVkOWQ5NjM2IiwidCI6IjRhMDQyNzQzLTM3M2EtNDNkMi04MjdiLTAwM2Y0YzdiYTFlNSIsImMiOjN9&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 26 Jun 2018 16:49:38 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Quick-Measures-Gallery/Covariance/m-p/379069#M115</guid>
      <dc:creator>Greg_Deckler</dc:creator>
      <dc:date>2018-06-26T16:49:38Z</dc:date>
    </item>
    <item>
      <title>Re: Covariance</title>
      <link>https://community.fabric.microsoft.com/t5/Quick-Measures-Gallery/Covariance/m-p/619693#M290</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="313" data-lia-user-login="Greg_Deckler" class="lia-mention lia-mention-user"&gt;Greg_Deckler&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks for providing this information.&lt;/P&gt;
&lt;P&gt;I have tried to calculate the Covariance based on your DAX code but the system is throwing an error unkown to me. Could you please take a look at the below DAX code? (Errors in Red color)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;Covariance = 
VAR AvgA = CALCULATE(AVERAGE('PeriodSummary-FLEXMUIRRebalancing'[Total Return]), ALL('PeriodSummary-FLEXMUIRRebalancing'))
VAR AvgB = CALCULATE(AVERAGE('PeriodSummary-FLEXMUIRRebalancing'[Benchmark Return]), ALL('PeriodSummary-FLEXMUIRRebalancing'))
VAR MyTable = SUMMARIZE('PeriodSummary-FLEXMUIRRebalancing', 'PeriodSummary-FLEXMUIRRebalancing'[Total Return], &lt;FONT color="#993300"&gt;"PeriodSummary-FLEXMUIRRebalancing"&lt;/FONT&gt;, ('PeriodSummary-FLEXMUIRRebalancing'[Total Return] - AvgA)*(MAX('PeriodSummary-FLEXMUIRRebalancing'[Benchmark Return] - AvgB) / CALCULATE(COUNTROWS('PeriodSummary-FLEXMUIRRebalancing'), ALL('PeriodSummary-FLEXMUIRRebalancing')))
&lt;FONT color="#993300"&gt;RETURN&lt;/FONT&gt; &lt;/PRE&gt;
&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Fri, 08 Feb 2019 19:04:51 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Quick-Measures-Gallery/Covariance/m-p/619693#M290</guid>
      <dc:creator>sv11</dc:creator>
      <dc:date>2019-02-08T19:04:51Z</dc:date>
    </item>
    <item>
      <title>Re: Covariance</title>
      <link>https://community.fabric.microsoft.com/t5/Quick-Measures-Gallery/Covariance/m-p/619805#M291</link>
      <description>&lt;P&gt;I think you are missing a closing paren, in red&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;Covariance = 
VAR AvgA = 
CALCULATE(
	AVERAGE('PeriodSummary-FLEXMUIRRebalancing'[Total Return]), 
	ALL('PeriodSummary-FLEXMUIRRebalancing')
)
VAR AvgB = 
CALCULATE(
	AVERAGE('PeriodSummary-FLEXMUIRRebalancing'[Benchmark Return]), 
	ALL('PeriodSummary-FLEXMUIRRebalancing')
)

VAR MyTable = 
SUMMARIZE(
	'PeriodSummary-FLEXMUIRRebalancing', 
	'PeriodSummary-FLEXMUIRRebalancing'[Total Return], 
	"PeriodSummary-FLEXMUIRRebalancing", 
	('PeriodSummary-FLEXMUIRRebalancing'[Total Return] - AvgA)
	*
	(MAX('PeriodSummary-FLEXMUIRRebalancing'[Benchmark Return]&lt;FONT face="arial black,avant garde"&gt;&lt;STRONG&gt;&lt;FONT color="#ff0000"&gt;)&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/FONT&gt; - AvgB) 
	/ 
	CALCULATE(
		COUNTROWS('PeriodSummary-FLEXMUIRRebalancing'), 
		ALL('PeriodSummary-FLEXMUIRRebalancing')
	)
)
RETURN &lt;/PRE&gt;</description>
      <pubDate>Sat, 09 Feb 2019 00:36:21 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Quick-Measures-Gallery/Covariance/m-p/619805#M291</guid>
      <dc:creator>Greg_Deckler</dc:creator>
      <dc:date>2019-02-09T00:36:21Z</dc:date>
    </item>
  </channel>
</rss>

