<?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: Calculating average between start and end dates in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-average-between-start-and-end-dates/m-p/2549619#M72097</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Sorry, I was a bit unclear.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need the measure in the same visual as my other measures that are depandant on the calendar table. So I have two different fact-tables, one with orders and one with estimated volume. Both are connected to the calendar table at the moment. And I would be very happy if it was possible to have all measures in the same line graph.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Sincerely&lt;/P&gt;&lt;P&gt;Dash&lt;/P&gt;</description>
    <pubDate>Tue, 31 May 2022 08:35:08 GMT</pubDate>
    <dc:creator>PBI-Dash</dc:creator>
    <dc:date>2022-05-31T08:35:08Z</dc:date>
    <item>
      <title>Calculating average between start and end dates</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-average-between-start-and-end-dates/m-p/2547676#M71996</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I'm struggling with a DAX expression where I want to calculate the average volume between a start and end date and after that applying this measure to a visual where the numbers are shown correctly.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The dataset is very simple and looks like this:&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Opportunity_Id&lt;/TD&gt;&lt;TD&gt;Est Volume&lt;/TD&gt;&lt;TD&gt;Opportunity Date Contract Start&lt;/TD&gt;&lt;TD&gt;Opportunity Date Contract End&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;123XXX&lt;/TD&gt;&lt;TD&gt;100&lt;/TD&gt;&lt;TD&gt;2021-08-12&lt;/TD&gt;&lt;TD&gt;2022-05-30&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;456XXX&lt;/TD&gt;&lt;TD&gt;5&lt;/TD&gt;&lt;TD&gt;2021-09-01&lt;/TD&gt;&lt;TD&gt;2022-06-15&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;789XXX&lt;/TD&gt;&lt;TD&gt;6&lt;/TD&gt;&lt;TD&gt;2022-01-17&lt;/TD&gt;&lt;TD&gt;2022-12-31&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;321XXX&lt;/TD&gt;&lt;TD&gt;50&lt;/TD&gt;&lt;TD&gt;2022-06-20&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;2022-09-29&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;BR /&gt;And I have a calendar table that has a relationship with this fact table through 'Calendar'[Date] 1:* 'fact_opportunites'[Opportunity_Date_Contract_Start].&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Let's take an example:&lt;/P&gt;&lt;P&gt;We have an opportunity where the estimated volume is 100. The contract lenght is 5 months. In this case I want to take the sum of the volume (100) and divide it by the number of months (5). And then show this number (20) across those 5 months that this contract is valid. Is there any way to do this?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've tried following &lt;A title="How to divide/distribute values between start date or end date or count days across months/days" href="https://community.powerbi.com/t5/Community-Blog/How-to-divide-distribute-values-between-start-date-or-end-date/ba-p/1503785" target="_blank" rel="noopener"&gt;this guide&lt;/A&gt;, but the result is that all the numbers are shown on either the month the contract starts or ends (depending on if the relationship is to&amp;nbsp;'fact_opportunites'[Opportunity_Date_Contract_Start] or&amp;nbsp;'fact_opportunites'[Opportunity_Date_Contract_End]). The measure looks like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Average estimated volume per Month = 
CALCULATE(
    SUMX(
        SUMMARIZE(
            filter(
                CROSSJOIN('fact_opportunities','Calendar')
                ,'Calendar'[Date] &amp;gt;= 'fact_opportunities'[Opportunity_Date_Contract_Start] &amp;amp;&amp;amp; 'Calendar'[Date]&amp;lt;= 'fact_opportunities'[Opportunity_Date_Contract_End]
            )
                ,'fact_opportunities'[Opportunity_Id]
                ,'Calendar'[Date]
                ,fact_opportunities[Opportunity_Estimated_Volume]
                ,fact_opportunities[Opportunity_Date_Contract_Start]
                ,fact_opportunities[Opportunity_Date_Contract_End]
        )
        ,DIVIDE(
            [Volume]
            ,
            DATEDIFF(fact_opportunities[Opportunity_Date_Contract_Start],fact_opportunities[Opportunity_Date_Contract_End],MONTH)+1)
    )
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So the average numbers are showing correctly, just that they are &lt;STRONG&gt;&lt;U&gt;only&lt;/U&gt;&lt;/STRONG&gt; showing on either the start or end month (depending on the relationship).&lt;/P&gt;&lt;P&gt;Or does somebody have a different approach on how to solve this?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you in advance!&lt;/P&gt;</description>
      <pubDate>Mon, 30 May 2022 11:35:56 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-average-between-start-and-end-dates/m-p/2547676#M71996</guid>
      <dc:creator>PBI-Dash</dc:creator>
      <dc:date>2022-05-30T11:35:56Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating average between start and end dates</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-average-between-start-and-end-dates/m-p/2547764#M72000</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;I am not sure how your expected outcome of the visualization looks like, but please check the below picture and the attached pbix file.&lt;/P&gt;
&lt;P&gt;I created no-relationship between the two tables in order to create a measure in a more easy way.&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;LI-CODE lang="markup"&gt;Monthly expected volume measure: =
VAR _startingmonth =
    EOMONTH ( SELECTEDVALUE ( Data[Opportunity Date Contract Start] ), -1 ) + 1
VAR _endingmonth =
    EOMONTH ( SELECTEDVALUE ( Data[Opportunity Date Contract End] ), 0 )
VAR _monthcount =
    COUNTROWS (
        SUMMARIZE (
            FILTER (
                ALL ( 'Calendar' ),
                'Calendar'[Date] &amp;gt;= _startingmonth
                    &amp;amp;&amp;amp; 'Calendar'[Date] &amp;lt;= _endingmonth
            ),
            'Calendar'[Month &amp;amp; Year CC]
        )
    )
VAR _EstVolumeAVG =
    DIVIDE ( SUM ( Data[Est Volume] ), _monthcount )
RETURN
    IF (
        MIN ( 'Calendar'[Date] ) &amp;gt;= _startingmonth
            &amp;amp;&amp;amp; MAX ( 'Calendar'[Date] ) &amp;lt;= _endingmonth,
        _EstVolumeAVG,
        0
    )
&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 30 May 2022 12:16:09 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-average-between-start-and-end-dates/m-p/2547764#M72000</guid>
      <dc:creator>Jihwan_Kim</dc:creator>
      <dc:date>2022-05-30T12:16:09Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating average between start and end dates</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-average-between-start-and-end-dates/m-p/2547940#M72014</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Thanks for the reply!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Sorry, I forgot to mention how I'd like to visualize it.&lt;/P&gt;&lt;P&gt;In this case I'd like to visualize the numbers in a line chart where I also show the orders current year as well as orders last year. So this measure would somehow need to be connected to the calendar table that I'm using as an axis.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Sincerely&lt;/P&gt;&lt;P&gt;Dash&lt;/P&gt;</description>
      <pubDate>Mon, 30 May 2022 13:40:22 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-average-between-start-and-end-dates/m-p/2547940#M72014</guid>
      <dc:creator>PBI-Dash</dc:creator>
      <dc:date>2022-05-30T13:40:22Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating average between start and end dates</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-average-between-start-and-end-dates/m-p/2548047#M72020</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;Thank you for your feedback.&lt;/P&gt;
&lt;P&gt;I am not sure if I understood your inquiry correctly, but please check the below picture and the attached pbix file.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 30 May 2022 14:29:06 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-average-between-start-and-end-dates/m-p/2548047#M72020</guid>
      <dc:creator>Jihwan_Kim</dc:creator>
      <dc:date>2022-05-30T14:29:06Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating average between start and end dates</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-average-between-start-and-end-dates/m-p/2549619#M72097</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Sorry, I was a bit unclear.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need the measure in the same visual as my other measures that are depandant on the calendar table. So I have two different fact-tables, one with orders and one with estimated volume. Both are connected to the calendar table at the moment. And I would be very happy if it was possible to have all measures in the same line graph.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Sincerely&lt;/P&gt;&lt;P&gt;Dash&lt;/P&gt;</description>
      <pubDate>Tue, 31 May 2022 08:35:08 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-average-between-start-and-end-dates/m-p/2549619#M72097</guid>
      <dc:creator>PBI-Dash</dc:creator>
      <dc:date>2022-05-31T08:35:08Z</dc:date>
    </item>
  </channel>
</rss>

