<?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 Calculated column for each row across multiple tables in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculated-column-for-each-row-across-multiple-tables/m-p/772829#M3754</link>
    <description>&lt;P&gt;Hi everyone,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a table 'ClientInfo' which has (among others) three columns: BeginDate, EndDate, TotalCostsPerDay. Additionally, I have a table called 'DateValues' which has a column called 'Dates'.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to add a calculated column 'AggregateCostPerDay' to 'DateValues', where the n-th value is defined as follows:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;- Take the 'DateValues'[Dates] value of the n-th row (call this date 'x');&lt;BR /&gt;- Get all rows of 'ClientInfo' where the date-range (BeginDate, EndDate) contains this date 'x';&lt;BR /&gt;- For these rows, take the sum of the 'TotalCostPerDay' values;&lt;BR /&gt;- This sum is the n-th vale of the 'AggregateCostPerDay' column.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have the following DAX statement, which is not working:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;'DateValues'[AggregateCostPerDay] = CALCULATE(SUMX( FILTER(ClientInfo, BeginDate &amp;lt;= 'DateValues'[Dates] &amp;amp;&amp;amp; 'DateValues'[Dates] &amp;lt;= EndDate) ))&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It's not working because inside the SUMX, 'DateValues'[Dates] is the problem. I would need something like:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;'DateValues'[AggregateCostPerDay] = For each 'Date' in 'DateValues'[Dates], CALCULATE(SUMX( FILTER(ClientInfo, BeginDate &amp;lt;= 'Date' &amp;amp;&amp;amp; 'Date' &amp;lt;= EndDate) ))&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How would I have to do this?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance!&lt;/P&gt;</description>
    <pubDate>Thu, 22 Aug 2019 09:02:10 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2019-08-22T09:02:10Z</dc:date>
    <item>
      <title>Calculated column for each row across multiple tables</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculated-column-for-each-row-across-multiple-tables/m-p/772829#M3754</link>
      <description>&lt;P&gt;Hi everyone,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a table 'ClientInfo' which has (among others) three columns: BeginDate, EndDate, TotalCostsPerDay. Additionally, I have a table called 'DateValues' which has a column called 'Dates'.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to add a calculated column 'AggregateCostPerDay' to 'DateValues', where the n-th value is defined as follows:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;- Take the 'DateValues'[Dates] value of the n-th row (call this date 'x');&lt;BR /&gt;- Get all rows of 'ClientInfo' where the date-range (BeginDate, EndDate) contains this date 'x';&lt;BR /&gt;- For these rows, take the sum of the 'TotalCostPerDay' values;&lt;BR /&gt;- This sum is the n-th vale of the 'AggregateCostPerDay' column.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have the following DAX statement, which is not working:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;'DateValues'[AggregateCostPerDay] = CALCULATE(SUMX( FILTER(ClientInfo, BeginDate &amp;lt;= 'DateValues'[Dates] &amp;amp;&amp;amp; 'DateValues'[Dates] &amp;lt;= EndDate) ))&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It's not working because inside the SUMX, 'DateValues'[Dates] is the problem. I would need something like:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;'DateValues'[AggregateCostPerDay] = For each 'Date' in 'DateValues'[Dates], CALCULATE(SUMX( FILTER(ClientInfo, BeginDate &amp;lt;= 'Date' &amp;amp;&amp;amp; 'Date' &amp;lt;= EndDate) ))&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How would I have to do this?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance!&lt;/P&gt;</description>
      <pubDate>Thu, 22 Aug 2019 09:02:10 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculated-column-for-each-row-across-multiple-tables/m-p/772829#M3754</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-08-22T09:02:10Z</dc:date>
    </item>
    <item>
      <title>Re: Calculated column for each row across multiple tables</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculated-column-for-each-row-across-multiple-tables/m-p/774010#M3822</link>
      <description>&lt;P&gt;try this as a calculated column in 'DateValues'&lt;/P&gt;&lt;PRE&gt;AggregateCostPerDay =
VAR __Date = 'DateValues'[Dates]
VAR __ClientInfo =
    FILTER (
        'ClientInfo',
        'ClientInfo'[BeginDate] &amp;lt;= __Date
            &amp;amp;&amp;amp; 'ClientInfo'[EndDate] &amp;gt;= __Date
    )
RETURN
    SUMX ( __ClientInfo, [TotalCostsPerDay] )&lt;/PRE&gt;&lt;P&gt;if it doesn't work - can you add sample tables (in format that can be copied to PowerBI) from your model with anonymised data? Like this (just copy and paste into the post window).&lt;/P&gt;&lt;TABLE border="0" cellspacing="0" cellpadding="0"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Column1&lt;/TD&gt;&lt;TD&gt;Column2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;A&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;B&lt;/TD&gt;&lt;TD&gt;2.5&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 23 Aug 2019 07:52:54 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculated-column-for-each-row-across-multiple-tables/m-p/774010#M3822</guid>
      <dc:creator>Stachu</dc:creator>
      <dc:date>2019-08-23T07:52:54Z</dc:date>
    </item>
  </channel>
</rss>

