<?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: Correlation between multiple columns in multiple tables (3 types of calculation involved) in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Correlation-between-multiple-columns-in-multiple-tables-3-types/m-p/3046794#M104761</link>
    <description>&lt;P&gt;here is the updates on the progress&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;[Update of the Progress]&lt;/P&gt;&lt;P&gt;I am using the 2nd method I have mentioned (2. Append the 17 tables (Topix-17 series) into a new table), and the issue I have mentioned is solved.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Syntax for each colum is below:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Column 'PreValue'&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;PreValue = CALCULATE(MAX('TOPIX-17 Series'[Price]),
                 ALL('TOPIX-17 Series'),
                 'TOPIX-17 Series'[Index Name] = EARLIER('TOPIX-17 Series'[Index Name]),
                 'TOPIX-17 Series'[Index] = EARLIER('TOPIX-17 Series'[Index])+1
                 )&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Column 'Monthly Return'&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Monthly Return = IF('TOPIX-17 Series'[PreValue] = BLANK(),
                   BLANK(),
                   ('TOPIX-17 Series'[Price]/'TOPIX-17 Series'[PreValue])-1)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Column 'Active Return'&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Active Return = [Monthly Return] - RELATED('Topix_TRN'[Monthly Return])&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How the table looks like:&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Column 'Correlation_S&amp;amp;P'&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Correlation_S&amp;amp;P = 
VAR __CORRELATION_TABLE = VALUES('TOPIX-17 Series'[Index Name])
VAR __COUNT =
	COUNTX(
		KEEPFILTERS(__CORRELATION_TABLE),
		CALCULATE(
			SUM('S&amp;amp;P500_TRN'[Monthly Return])
				* SUM('TOPIX-17 Series'[Active Return])
		)
	)
VAR __SUM_X =
	SUMX(
		KEEPFILTERS(__CORRELATION_TABLE),
		CALCULATE(SUM('S&amp;amp;P500_TRN'[Monthly Return]))
	)
VAR __SUM_Y =
	SUMX(
		KEEPFILTERS(__CORRELATION_TABLE),
		CALCULATE(SUM('TOPIX-17 Series'[Active Return]))
	)
VAR __SUM_XY =
	SUMX(
		KEEPFILTERS(__CORRELATION_TABLE),
		CALCULATE(
			SUM('S&amp;amp;P500_TRN'[Monthly Return])
				* SUM('TOPIX-17 Series'[Active Return]) * 1.
		)
	)
VAR __SUM_X2 =
	SUMX(
		KEEPFILTERS(__CORRELATION_TABLE),
		CALCULATE(SUM('S&amp;amp;P500_TRN'[Monthly Return]) ^ 2)
	)
VAR __SUM_Y2 =
	SUMX(
		KEEPFILTERS(__CORRELATION_TABLE),
		CALCULATE(SUM('TOPIX-17 Series'[Active Return]) ^ 2)
	)
RETURN
    DIVIDE(
		__COUNT * __SUM_XY - __SUM_X * __SUM_Y * 1.,
		SQRT(
			(__COUNT * __SUM_X2 - __SUM_X ^ 2)
				* (__COUNT * __SUM_Y2 - __SUM_Y ^ 2)
		)
	)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The syntax does not have errors, but the column does not show any value or error.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If you have ideas how to solve this, please help me&lt;span class="lia-unicode-emoji" title=":folded_hands:"&gt;🙏&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you all in advance&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Peru&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;</description>
    <pubDate>Fri, 27 Jan 2023 08:57:56 GMT</pubDate>
    <dc:creator>Peru123</dc:creator>
    <dc:date>2023-01-27T08:57:56Z</dc:date>
    <item>
      <title>Correlation between multiple columns in multiple tables (3 types of calculation involved)</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Correlation-between-multiple-columns-in-multiple-tables-3-types/m-p/3024889#M103093</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need help with correlation table creation.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;[Goal]&lt;/P&gt;&lt;P&gt;To create a correlation table like below to see the correlation (*3) between Active Return (*2) of Topix-17 Series and Monthly Return (*1) of several Indexes (trying with S&amp;amp;P500 to begin with).&lt;/P&gt;&lt;P&gt;As the data to be added regularly, I wish to do the calculation on Power BI instead of Excel.&lt;/P&gt;&lt;P&gt;Below is the output I made on Power BI with Excel calculated data.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;X-Axis: Topix-17 Series&lt;/P&gt;&lt;P&gt;Y-Axis: Several Indexes (incl.S&amp;amp;P500)&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;[Indexes (Data)]&lt;/P&gt;&lt;P&gt;Columns and the number of rows are the same for every index (table), Total = 19 Indexes (tables)&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Topix-17 Series: 17 Indexes by industry categories. 17 historical month-end price tables.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Topix Total Return Index&lt;/LI&gt;&lt;LI&gt;S&amp;amp;P500 Total Return Index&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;*1 Monthly Return = Monthly percentage change in ‘Price’&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; :Monthly return to be calculated for all the indexes (19 indexes)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;*2 Active Return = ‘Monthly Return of Each Topix-17 Index’ – ‘Monthly Return of Topix Total Return Index’&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;*3 Correlation: between ‘Active Return’ of each index of Topix-17 Series &amp;amp; ‘Monthly Return’ of S&amp;amp;P500 Total Return Index&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;[Excel Calculation]&lt;/P&gt;&lt;P&gt;Hope this would explain the logics of calculations I would like to do on Power BI&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Monthly Return:&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Active Return:&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Correlation:&lt;/P&gt;&lt;P&gt;&lt;img /&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;[Methods Tried &amp;amp; Issues]&lt;/P&gt;&lt;P&gt;1. Inserting Index column to shift the Price value by one row&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;Issue: This method couldn’t put all 17 correlation values into one column, so the visual output cannot be how I want.&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;Solution required: If the correlation values could be calculated in one column, the output can be what I want.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2. Append the 17 tables (Topix-17 series) into a new table&lt;/P&gt;&lt;P&gt;(Creating a PreValue column by shifting the Prive value by one row)&lt;/P&gt;&lt;P&gt;Issue: Cannot shift the Price value by one row as the bottom row for each Index would calculate wrong&lt;/P&gt;&lt;P&gt;Solution required: if the Monthly return could be calculated without creating the PreValue column, this method may work&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If anyone of you have ideas on the above, please tell me your ideas.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you all in advance&lt;span class="lia-unicode-emoji" title=":folded_hands:"&gt;🙏&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Peru&lt;/P&gt;</description>
      <pubDate>Tue, 17 Jan 2023 06:44:02 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Correlation-between-multiple-columns-in-multiple-tables-3-types/m-p/3024889#M103093</guid>
      <dc:creator>Peru123</dc:creator>
      <dc:date>2023-01-17T06:44:02Z</dc:date>
    </item>
    <item>
      <title>Re: Correlation between multiple columns in multiple tables (3 types of calculation involved)</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Correlation-between-multiple-columns-in-multiple-tables-3-types/m-p/3046794#M104761</link>
      <description>&lt;P&gt;here is the updates on the progress&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;[Update of the Progress]&lt;/P&gt;&lt;P&gt;I am using the 2nd method I have mentioned (2. Append the 17 tables (Topix-17 series) into a new table), and the issue I have mentioned is solved.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Syntax for each colum is below:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Column 'PreValue'&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;PreValue = CALCULATE(MAX('TOPIX-17 Series'[Price]),
                 ALL('TOPIX-17 Series'),
                 'TOPIX-17 Series'[Index Name] = EARLIER('TOPIX-17 Series'[Index Name]),
                 'TOPIX-17 Series'[Index] = EARLIER('TOPIX-17 Series'[Index])+1
                 )&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Column 'Monthly Return'&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Monthly Return = IF('TOPIX-17 Series'[PreValue] = BLANK(),
                   BLANK(),
                   ('TOPIX-17 Series'[Price]/'TOPIX-17 Series'[PreValue])-1)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Column 'Active Return'&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Active Return = [Monthly Return] - RELATED('Topix_TRN'[Monthly Return])&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How the table looks like:&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Column 'Correlation_S&amp;amp;P'&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Correlation_S&amp;amp;P = 
VAR __CORRELATION_TABLE = VALUES('TOPIX-17 Series'[Index Name])
VAR __COUNT =
	COUNTX(
		KEEPFILTERS(__CORRELATION_TABLE),
		CALCULATE(
			SUM('S&amp;amp;P500_TRN'[Monthly Return])
				* SUM('TOPIX-17 Series'[Active Return])
		)
	)
VAR __SUM_X =
	SUMX(
		KEEPFILTERS(__CORRELATION_TABLE),
		CALCULATE(SUM('S&amp;amp;P500_TRN'[Monthly Return]))
	)
VAR __SUM_Y =
	SUMX(
		KEEPFILTERS(__CORRELATION_TABLE),
		CALCULATE(SUM('TOPIX-17 Series'[Active Return]))
	)
VAR __SUM_XY =
	SUMX(
		KEEPFILTERS(__CORRELATION_TABLE),
		CALCULATE(
			SUM('S&amp;amp;P500_TRN'[Monthly Return])
				* SUM('TOPIX-17 Series'[Active Return]) * 1.
		)
	)
VAR __SUM_X2 =
	SUMX(
		KEEPFILTERS(__CORRELATION_TABLE),
		CALCULATE(SUM('S&amp;amp;P500_TRN'[Monthly Return]) ^ 2)
	)
VAR __SUM_Y2 =
	SUMX(
		KEEPFILTERS(__CORRELATION_TABLE),
		CALCULATE(SUM('TOPIX-17 Series'[Active Return]) ^ 2)
	)
RETURN
    DIVIDE(
		__COUNT * __SUM_XY - __SUM_X * __SUM_Y * 1.,
		SQRT(
			(__COUNT * __SUM_X2 - __SUM_X ^ 2)
				* (__COUNT * __SUM_Y2 - __SUM_Y ^ 2)
		)
	)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The syntax does not have errors, but the column does not show any value or error.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If you have ideas how to solve this, please help me&lt;span class="lia-unicode-emoji" title=":folded_hands:"&gt;🙏&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you all in advance&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Peru&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;</description>
      <pubDate>Fri, 27 Jan 2023 08:57:56 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Correlation-between-multiple-columns-in-multiple-tables-3-types/m-p/3046794#M104761</guid>
      <dc:creator>Peru123</dc:creator>
      <dc:date>2023-01-27T08:57:56Z</dc:date>
    </item>
    <item>
      <title>Re: Correlation between multiple columns in multiple tables (3 types of calculation involved)</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Correlation-between-multiple-columns-in-multiple-tables-3-types/m-p/3049529#M104982</link>
      <description>&lt;P&gt;FYI, below is how the tables are interrelated&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 30 Jan 2023 06:11:09 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Correlation-between-multiple-columns-in-multiple-tables-3-types/m-p/3049529#M104982</guid>
      <dc:creator>Peru123</dc:creator>
      <dc:date>2023-01-30T06:11:09Z</dc:date>
    </item>
  </channel>
</rss>

