<?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: Calculate a measure that has a single value for multiple rows in a table in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-a-measure-that-has-a-single-value-for-multiple-rows-in/m-p/1577829#M31507</link>
    <description>&lt;P&gt;&lt;SPAN&gt;Time intelligence should not be attempted with a single flat table. &amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;You should get a calendar table for this problem.&amp;nbsp;&lt;/SPAN&gt;&lt;A href="https://exceleratorbi.com.au/power-pivot-calendar-tables/" target="_blank" rel="noopener"&gt;https://exceleratorbi.com.au/power-pivot-calendar-tables/&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Join the calendar table to the date column of the data table&lt;/P&gt;&lt;P&gt;switch all references to date from your data table to the calendar table, including in the visuals/slicers&lt;/P&gt;&lt;P&gt;Once you make these changes, your first attempt should work.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;the reason it doesn't work with a single table is complex. It has to do with the way the source data is compressed and stored in the database. Removing a filter from a subset of columns, eg ALL(table[column]) or ALLSELECTED(table) will not behave as you expect because of the binding of rows of data together caused by the storage. This row binding does not occur when you use a dimension table&lt;/P&gt;</description>
    <pubDate>Sat, 02 Jan 2021 21:18:03 GMT</pubDate>
    <dc:creator>MattAllington</dc:creator>
    <dc:date>2021-01-02T21:18:03Z</dc:date>
    <item>
      <title>Calculate a measure that has a single value for multiple rows in a table</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-a-measure-that-has-a-single-value-for-multiple-rows-in/m-p/1577387#M31497</link>
      <description>&lt;P&gt;I am working with stock data in a table that includes a ticker column, a date column and a End of Day (EOD) stock value column. I have added an integer column with with a counter for trading dates.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to calculate for each ticker what the EOD value is at the start of a selection range, so I can use that number to calculate the growth of the the stock value over time as a percentage of the value at that start date.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My intermediate measures look like this:&amp;nbsp;&lt;/P&gt;&lt;P&gt;EOD Average =average(DALL_CURRENT[EOD])&lt;/P&gt;&lt;P&gt;Ticker in context =FIRSTNONBLANK(DALL_CURRENT[Ticker],DALL_CURRENT[Ticker])&lt;/P&gt;&lt;P&gt;First trading day&amp;nbsp; =min(DALL_CURRENT[Trading day])&lt;/P&gt;&lt;P&gt;First trading day in selection=calculate([First trading day],allselected(DALL_CURRENT))&lt;/P&gt;&lt;P&gt;This works great. The identifier for the first trading day in my selection is assigned to each date in my selection.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now I want to use this "First trading day in selection" measure to select the EOD value for each ticker at the start date.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My first attempt looks like this:&amp;nbsp;&lt;/P&gt;&lt;P&gt;=calculate([EOD Average],Filter(all(DALL_CURRENT[Trading day]),DALL_CURRENT[Trading day]=[First trading day in selection]))&lt;/P&gt;&lt;P&gt;What is &lt;STRONG&gt;good&lt;/STRONG&gt; here is that I get the right values for multiple Tickers&lt;/P&gt;&lt;P&gt;The &lt;STRONG&gt;problem&lt;/STRONG&gt; here is that I only get a result for the first trading day and not for all the other dates.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My second attempt to avoid the filter context issue was to build an interim table&amp;nbsp;&lt;/P&gt;&lt;P&gt;=VAR TMP =&lt;BR /&gt;FILTER (&lt;BR /&gt;SELECTCOLUMNS (&lt;BR /&gt;ALL ( 'DALL_CURRENT'),&lt;BR /&gt;"TMP[TD]", DALL_CURRENT[Trading day],&lt;BR /&gt;"TMP[EOD]", DALL_CURRENT[EOD],&lt;BR /&gt;"TMP[Ticker]",DALL_CURRENT[Ticker] ),&lt;BR /&gt;TMP[TD]=[First trading day in selection] &amp;amp;&amp;amp; TMP[Ticker]=[Ticker in context]&lt;BR /&gt;)&lt;BR /&gt;VAR EOD_at_Start = averagex(TMP,TMP[EOD])&lt;/P&gt;&lt;P&gt;RETURN EOD_at_Start&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I got exactly the same result.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My questions are:&lt;/P&gt;&lt;P&gt;1: why is it that I only see an answer for the first trading date? I kind of understand it for the first calculation, but not for the second.&lt;/P&gt;&lt;P&gt;2: how can I get the right answer for all dates within my selection?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 01 Jan 2021 21:48:08 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-a-measure-that-has-a-single-value-for-multiple-rows-in/m-p/1577387#M31497</guid>
      <dc:creator>dbongers</dc:creator>
      <dc:date>2021-01-01T21:48:08Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate a measure that has a single value for multiple rows in a table</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-a-measure-that-has-a-single-value-for-multiple-rows-in/m-p/1577829#M31507</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Time intelligence should not be attempted with a single flat table. &amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;You should get a calendar table for this problem.&amp;nbsp;&lt;/SPAN&gt;&lt;A href="https://exceleratorbi.com.au/power-pivot-calendar-tables/" target="_blank" rel="noopener"&gt;https://exceleratorbi.com.au/power-pivot-calendar-tables/&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Join the calendar table to the date column of the data table&lt;/P&gt;&lt;P&gt;switch all references to date from your data table to the calendar table, including in the visuals/slicers&lt;/P&gt;&lt;P&gt;Once you make these changes, your first attempt should work.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;the reason it doesn't work with a single table is complex. It has to do with the way the source data is compressed and stored in the database. Removing a filter from a subset of columns, eg ALL(table[column]) or ALLSELECTED(table) will not behave as you expect because of the binding of rows of data together caused by the storage. This row binding does not occur when you use a dimension table&lt;/P&gt;</description>
      <pubDate>Sat, 02 Jan 2021 21:18:03 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-a-measure-that-has-a-single-value-for-multiple-rows-in/m-p/1577829#M31507</guid>
      <dc:creator>MattAllington</dc:creator>
      <dc:date>2021-01-02T21:18:03Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate a measure that has a single value for multiple rows in a table</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-a-measure-that-has-a-single-value-for-multiple-rows-in/m-p/1578647#M31537</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="233590" data-lia-user-login="dbongers" class="lia-mention lia-mention-user"&gt;dbongers&lt;/a&gt; ,Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.&lt;/P&gt;</description>
      <pubDate>Mon, 04 Jan 2021 05:19:09 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-a-measure-that-has-a-single-value-for-multiple-rows-in/m-p/1578647#M31537</guid>
      <dc:creator>amitchandak</dc:creator>
      <dc:date>2021-01-04T05:19:09Z</dc:date>
    </item>
  </channel>
</rss>

