<?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: Two dropdown menus to select two columns and calculate the difference/correlation in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Two-dropdown-menus-to-select-two-columns-and-calculate-the/m-p/4607837#M176388</link>
    <description>&lt;P&gt;May I ask one more question about the use of &lt;STRONG&gt;VALUES()&lt;/STRONG&gt; in the following DAX?&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Slope = 
VAR RegressionResult =
    LINESTX (
        VALUES ( Days[Day] ),
        [Score Person 2],
        [Score Person 1]
    )...&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If I replace VALUES(Days[Day]) with Data like the following, the calculation of Slope will be wrong and [Score Person 2] seems to always return zeros.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Slope = 
VAR RegressionResult =
    LINESTX (
        Data,
        [Score Person 2],
        [Score Person 1]
    )...&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks again.&lt;/P&gt;</description>
    <pubDate>Thu, 13 Mar 2025 03:51:29 GMT</pubDate>
    <dc:creator>kc_1116</dc:creator>
    <dc:date>2025-03-13T03:51:29Z</dc:date>
    <item>
      <title>Two dropdown menus to select two columns and calculate the difference/correlation</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Two-dropdown-menus-to-select-two-columns-and-calculate-the/m-p/4601847#M176169</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am looking to create two dropdown menus to select two arbitary persons from the data set and calculate the difference in each day or the correlation.&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;&lt;P&gt;The original dataset in in wide format. Mindful that it is not the ideal format in Power BI, I have unpivot it into a long format.&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Day&lt;/TD&gt;&lt;TD&gt;Anne&lt;/TD&gt;&lt;TD&gt;Bill&lt;/TD&gt;&lt;TD&gt;Charles&lt;/TD&gt;&lt;TD&gt;David&lt;/TD&gt;&lt;TD&gt;Evan&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;2.5&lt;/TD&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;2.5&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;4&lt;/TD&gt;&lt;TD&gt;2.5&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, I struggled to create a calculate the score difference between two person in each day. I tried to use do so by using NATURALJOIN and SELECTEDVALUE, but SELECTEDVALUE always return empty instead of what is selected in the dropdown menu.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please find below the link to my Power BI file&lt;/P&gt;&lt;P&gt;&lt;A href="https://limewire.com/d/997fa681-3d66-4657-a310-6a6901ef5466#iQGXUyBikm-_s5Ox-hS2APKQ5G5LUEo7NrGi5-r29kM" target="_blank" rel="noopener"&gt;https://limewire.com/d/997fa681-3d66-4657-a310-6a6901ef5466#iQGXUyBikm-_s5Ox-hS2APKQ5G5LUEo7NrGi5-r29kM&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can you point me to the right direction please? Thanks a million.&lt;/P&gt;</description>
      <pubDate>Sun, 09 Mar 2025 02:32:11 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Two-dropdown-menus-to-select-two-columns-and-calculate-the/m-p/4601847#M176169</guid>
      <dc:creator>kc_1116</dc:creator>
      <dc:date>2025-03-09T02:32:11Z</dc:date>
    </item>
    <item>
      <title>Re: Two dropdown menus to select two columns and calculate the difference/correlation</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Two-dropdown-menus-to-select-two-columns-and-calculate-the/m-p/4601978#M176173</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="1235520" data-lia-user-login="kc_1116" class="lia-mention lia-mention-user"&gt;kc_1116&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For pairwise comparison calculations, I would suggest setting up the model in a similar way to the "&lt;A href="https://www.daxpatterns.com/comparing-different-time-periods/" target="_blank" rel="noopener"&gt;Comparing different time periods" pattern&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have attached your PBIX modified to use this method.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This is how I would suggest setting up the model:&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;This avoids duplicating the &lt;STRONG&gt;Data&lt;/STRONG&gt; table.&lt;/LI&gt;
&lt;LI&gt;Measure values based on filters on&amp;nbsp;&lt;STRONG&gt;'Person 2'&lt;/STRONG&gt;&amp;nbsp;rely on DAX to remove filters on &lt;STRONG&gt;'Person 1'&lt;/STRONG&gt; and activate the relationship between &lt;STRONG&gt;'Person 1'&lt;/STRONG&gt; and &lt;STRONG&gt;'Person 2' &lt;/STRONG&gt;(see below).&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;You can then write measures like these:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Score Person 1 = 
SUM ( Data[Score] )&lt;/LI-CODE&gt;&lt;LI-CODE lang="markup"&gt;Score Person 2 = 
CALCULATE (
    [Score Person 1],
    REMOVEFILTERS ( 'Person 1' ),
    USERELATIONSHIP ( 'Person 1'[Person 1], 'Person 2'[Person 2] )
)&lt;/LI-CODE&gt;&lt;LI-CODE lang="markup"&gt;Variance Person 1 vs Person 2 = 
[Score Person 1] - [Score Person 2]&lt;/LI-CODE&gt;&lt;LI-CODE lang="markup"&gt;Coefficient of Determination = 
VAR RegressionResult =
    LINESTX (
        VALUES ( Days[Day] ),
        [Score Person 2],
        [Score Person 1]
    )
VAR Result =
    SELECTCOLUMNS ( RegressionResult, [CoefficientOfDetermination] )
RETURN
    Result&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Note:&lt;/STRONG&gt; For the measures using LINESTX, (&lt;STRONG&gt;Coefficient of Determination&lt;/STRONG&gt;, &lt;STRONG&gt;Slope&lt;/STRONG&gt; and &lt;STRONG&gt;Intercept&lt;/STRONG&gt;), I treated &lt;STRONG&gt;Score Person 2&lt;/STRONG&gt; as the dependent variable and &lt;STRONG&gt;Score Person 1&lt;/STRONG&gt; as the independent variable. You may well want to switch these around.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;Would something like this work for you?&lt;/P&gt;</description>
      <pubDate>Sun, 09 Mar 2025 08:57:31 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Two-dropdown-menus-to-select-two-columns-and-calculate-the/m-p/4601978#M176173</guid>
      <dc:creator>OwenAuger</dc:creator>
      <dc:date>2025-03-09T08:57:31Z</dc:date>
    </item>
    <item>
      <title>Re: Two dropdown menus to select two columns and calculate the difference/correlation</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Two-dropdown-menus-to-select-two-columns-and-calculate-the/m-p/4602214#M176183</link>
      <description>&lt;P&gt;Thanks so much for solving the problem and explaining everthing in details. You made my day&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":grinning_face:"&gt;😀&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 09 Mar 2025 18:38:45 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Two-dropdown-menus-to-select-two-columns-and-calculate-the/m-p/4602214#M176183</guid>
      <dc:creator>kc_1116</dc:creator>
      <dc:date>2025-03-09T18:38:45Z</dc:date>
    </item>
    <item>
      <title>Re: Two dropdown menus to select two columns and calculate the difference/correlation</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Two-dropdown-menus-to-select-two-columns-and-calculate-the/m-p/4607837#M176388</link>
      <description>&lt;P&gt;May I ask one more question about the use of &lt;STRONG&gt;VALUES()&lt;/STRONG&gt; in the following DAX?&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Slope = 
VAR RegressionResult =
    LINESTX (
        VALUES ( Days[Day] ),
        [Score Person 2],
        [Score Person 1]
    )...&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If I replace VALUES(Days[Day]) with Data like the following, the calculation of Slope will be wrong and [Score Person 2] seems to always return zeros.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Slope = 
VAR RegressionResult =
    LINESTX (
        Data,
        [Score Person 2],
        [Score Person 1]
    )...&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks again.&lt;/P&gt;</description>
      <pubDate>Thu, 13 Mar 2025 03:51:29 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Two-dropdown-menus-to-select-two-columns-and-calculate-the/m-p/4607837#M176388</guid>
      <dc:creator>kc_1116</dc:creator>
      <dc:date>2025-03-13T03:51:29Z</dc:date>
    </item>
    <item>
      <title>Re: Two dropdown menus to select two columns and calculate the difference/correlation</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Two-dropdown-menus-to-select-two-columns-and-calculate-the/m-p/4609414#M176453</link>
      <description>&lt;P&gt;Sure thing &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://dax.guide/linestx/" target="_blank" rel="noopener"&gt;LINESTX&lt;/A&gt; is an iterator. The first argument provided to LINESTX is a table, and the 2nd and 3rd+ arguments will be evaluated for each row of that table.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In practice, the table provided for the first argument represents the granularity of data points for which you want to perform the regression calculation. If we want data points per Day, we should iterate over the values of the dimension column &lt;STRONG&gt;Days[Day]&lt;/STRONG&gt;.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In my suggested measure, I used&amp;nbsp;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;VALUES ( Days[Day] )&lt;/FONT&gt;&lt;/STRONG&gt; as the first argument. This expression returns a single-column table containing the distinct values of &lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;Days[Day]&lt;/FONT&gt;&lt;/STRONG&gt;:&lt;/P&gt;
&lt;TABLE style="height: 120px; width: 20%;" border="1" width="20%"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="100%" height="30px"&gt;&lt;STRONG&gt;Day&lt;/STRONG&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="100%" height="30px"&gt;1&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="100%" height="30px"&gt;2&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="100%" height="30px"&gt;3&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;LINESTX then evaluates &lt;STRONG&gt;Score Person 1&lt;/STRONG&gt; and &lt;STRONG&gt;Score Person 2&lt;/STRONG&gt; for each row of this table. You can think of this operation as each value of&amp;nbsp;&lt;STRONG&gt;Day&lt;/STRONG&gt;&amp;nbsp;from 1 to 3 being applied as a filter in turn, and the two scores evaluated with that filter applied.&lt;/P&gt;
&lt;P&gt;Assuming&amp;nbsp;&lt;STRONG&gt;Person 1 = "Bill"&lt;/STRONG&gt; and &lt;STRONG&gt;Person 2 = "David"&lt;/STRONG&gt;, LINESTX is working with these values:&lt;/P&gt;
&lt;TABLE style="width: 40%;" border="1" width="40%"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="33.333333333333336%" class="lia-align-center"&gt;&lt;STRONG&gt;Days[Day]&lt;/STRONG&gt;&lt;/TD&gt;
&lt;TD width="33.333333333333336%" class="lia-align-center"&gt;&lt;STRONG&gt;Score Person 1&lt;/STRONG&gt;&lt;/TD&gt;
&lt;TD width="33.333333333333336%" class="lia-align-center"&gt;&lt;STRONG&gt;Score Person 2&lt;/STRONG&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="33.333333333333336%" class="lia-align-center"&gt;1&lt;/TD&gt;
&lt;TD width="33.333333333333336%" class="lia-align-center"&gt;2&lt;/TD&gt;
&lt;TD width="33.333333333333336%" class="lia-align-center"&gt;3&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="33.333333333333336%" class="lia-align-center"&gt;2&lt;/TD&gt;
&lt;TD width="33.333333333333336%" class="lia-align-center"&gt;3&lt;/TD&gt;
&lt;TD width="33.333333333333336%" class="lia-align-center"&gt;2&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="33.333333333333336%" class="lia-align-center"&gt;3&lt;/TD&gt;
&lt;TD width="33.333333333333336%" class="lia-align-center"&gt;4&lt;/TD&gt;
&lt;TD width="33.333333333333336%" class="lia-align-center"&gt;1&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;You can check these values by running this query using ADDCOLUMNS (also an iterator) in &lt;A href="https://learn.microsoft.com/en-us/power-bi/transform-model/dax-query-view" target="_blank" rel="noopener"&gt;DAX query view&lt;/A&gt;:&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;EVALUATE
CALCULATETABLE (
    ADDCOLUMNS (
        VALUES ( Days[Day] ),
        "Score Person 1", [Score Person 1],
        "Score Person 2", [Score Person 2]
    ),
    'Person 1'[Person 1] = "Bill",
    'Person 2'[Person 2] = "David"
)
&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note that any rows where both &lt;STRONG&gt;Score Person 1&lt;/STRONG&gt; and &lt;STRONG&gt;Score Person 2&lt;/STRONG&gt; are blank would actually be ignored by LINESTX.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Back to your question: If you instead use &lt;STRONG&gt;Data&lt;/STRONG&gt; as the first argument of LINESTX, things go wrong because of the way filters interact, and the calculation of Scores and regression don't work as intended.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you run this DAX query to visualize the data LINESTX is working with, it becomes clearer:&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;EVALUATE
CALCULATETABLE (
    ADDCOLUMNS (
        Data,
        "Score Person 1", [Score Person 1],
        "Score Person 2", [Score Person 2]
    ),
    'Person 1'[Person 1] = "Bill",
    'Person 2'[Person 2] = "David"
)&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;TABLE border="1" width="100%"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="20%" class="lia-align-center"&gt;&lt;STRONG&gt;Data[Day]&lt;/STRONG&gt;&lt;/TD&gt;
&lt;TD width="20%" class="lia-align-center"&gt;&lt;STRONG&gt;Data[Person]&lt;/STRONG&gt;&lt;/TD&gt;
&lt;TD width="20%" class="lia-align-center"&gt;&lt;STRONG&gt;Data[Score]&lt;/STRONG&gt;&lt;/TD&gt;
&lt;TD width="20%" class="lia-align-center"&gt;&lt;STRONG&gt;[Score Person 1]&lt;/STRONG&gt;&lt;/TD&gt;
&lt;TD width="20%" class="lia-align-center"&gt;&lt;STRONG&gt;[Score Person 2]&lt;/STRONG&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="20%" class="lia-align-center"&gt;1&lt;/TD&gt;
&lt;TD width="20%" class="lia-align-center"&gt;Bill&lt;/TD&gt;
&lt;TD width="20%" class="lia-align-center"&gt;2&lt;/TD&gt;
&lt;TD width="20%" class="lia-align-center"&gt;2&lt;/TD&gt;
&lt;TD width="20%" class="lia-align-center"&gt;(blank)&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="20%" class="lia-align-center"&gt;2&lt;/TD&gt;
&lt;TD width="20%" class="lia-align-center"&gt;Bill&lt;/TD&gt;
&lt;TD width="20%" class="lia-align-center"&gt;3&lt;/TD&gt;
&lt;TD width="20%" class="lia-align-center"&gt;3&lt;/TD&gt;
&lt;TD width="20%" class="lia-align-center"&gt;(blank)&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="20%" class="lia-align-center"&gt;3&lt;/TD&gt;
&lt;TD width="20%" class="lia-align-center"&gt;Bill&lt;/TD&gt;
&lt;TD width="20%" class="lia-align-center"&gt;4&lt;/TD&gt;
&lt;TD width="20%" class="lia-align-center"&gt;4&lt;/TD&gt;
&lt;TD width="20%" class="lia-align-center"&gt;(blank)&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;The main issue here is that by iterating over the table&amp;nbsp;&lt;STRONG&gt;Data&lt;/STRONG&gt; (the fact table), the Score measures are evaluated with rows of the fact table applied as filters. The &lt;STRONG&gt;Score Person 1&lt;/STRONG&gt; and &lt;STRONG&gt;Score Person 2&lt;/STRONG&gt; measures are written with the intention of filters being applied to columns of dimension tables: &lt;STRONG&gt;Days, Person 1&lt;/STRONG&gt; and&amp;nbsp;&lt;STRONG&gt;Person&lt;/STRONG&gt; &lt;STRONG&gt;2&lt;/STRONG&gt;.&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Since we have an existing filter &lt;STRONG&gt;Person 1 = "Bill"&lt;/STRONG&gt;, the rows of the fact table are limited to those where &lt;STRONG&gt;Data[Person] = "Bill"&lt;/STRONG&gt;. This happens to be fine for &lt;STRONG&gt;Score Person 1&lt;/STRONG&gt; but not &lt;STRONG&gt;Score Person 2&lt;/STRONG&gt;.&lt;/LI&gt;
&lt;LI&gt;&lt;STRONG&gt;Score Person 2&lt;/STRONG&gt; removes filters on Person 1 and activates the relationship between Person 1 and Person 2, but this conflicts with the filter &lt;STRONG&gt;Data[Person] = "Bill"&lt;/STRONG&gt; coming from &lt;A href="https://www.sqlbi.com/articles/understanding-context-transition-in-dax/" target="_blank" rel="noopener"&gt;context transition&lt;/A&gt; when &lt;STRONG&gt;Score Person 2&lt;/STRONG&gt; is evaluated in each row of this table.&lt;/LI&gt;
&lt;LI&gt;Another potential problem: We don't know in advance if there are multiple rows in Data for each Day/Person combination. Bill could have two rows on Day 1 which should be summed to a single value per day (as with the original measure), not treated as separate data points (as with this version of the measure).&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;The key thing to remember is that when using LINESTX or any iterator function, the table argument determines the "granularity" of the calculation. Expressions evaluated by the iterator will be evaluated once per row of the table argument provided.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I realise there were a few points involved in that explanation. Hopefully that makes sense &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 14 Mar 2025 00:25:46 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Two-dropdown-menus-to-select-two-columns-and-calculate-the/m-p/4609414#M176453</guid>
      <dc:creator>OwenAuger</dc:creator>
      <dc:date>2025-03-14T00:25:46Z</dc:date>
    </item>
    <item>
      <title>Re: Two dropdown menus to select two columns and calculate the difference/correlation</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Two-dropdown-menus-to-select-two-columns-and-calculate-the/m-p/4617312#M176703</link>
      <description>&lt;P&gt;After studying your reply and reading the DAX Definitive Guide, I believe my wrong DAX is probably translated into the following code by the DAX engine due to context transition as the row context is invalidated by the implicit surrounding CALCULATE when a measure is used.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;VAR RegressionResult =
    LINESTX (
        -- VALUES ( Days[Day] ),	// This is correct
		Data,						// This is wrong
        CALCULATE(					// Context transition
			SUM(Data[Score]),
			Data[Person] = "Bill"
		),
        CALCULATE(
			SUM(Data[Score]),
			REMOVEFILTERS ( 'Person 1' ),
    		USERELATIONSHIP ( 'Person 1'[Person 1], 'Person 2'[Person 2] ),
			Data[Person] = "Bill",	// Conflict
			Data[Person] = "David"	// Conflict
		)
    )
VAR Result =
    SELECTCOLUMNS ( RegressionResult, [Slope1] )
RETURN
    Result&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 19 Mar 2025 23:39:35 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Two-dropdown-menus-to-select-two-columns-and-calculate-the/m-p/4617312#M176703</guid>
      <dc:creator>kc_1116</dc:creator>
      <dc:date>2025-03-19T23:39:35Z</dc:date>
    </item>
  </channel>
</rss>

