<?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: weighted average date in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/weighted-average-date/m-p/1825801#M38758</link>
    <description>&lt;P&gt;Hi&amp;nbsp;Anonymous&lt;/LI-USER&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Yes, that's exactly the idea.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In DAX, I would write something like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Average days sold-paid =
VAR TotalAmountSold =
    SUM ( Sales[Amount Sold] )
RETURN
    DIVIDE (
        SUMX ( Sales, ( Sales[Day Paid] - Sales[Day Sold] ) * Sales[Amount Sold] ),
        TotalAmountSold
    )&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Another version that could improve performance depending on distribution of your dates, especially if you have the same pairs of dates occurring repeatedly:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Average days sold-paid =
VAR TotalAmountSold =
    SUM ( Sales[Amount Sold] )
RETURN
    DIVIDE (
        SUMX (
            SUMMARIZE ( Sales, Sales[Day Paid], Sales[Day Sold] ),
            ( Sales[Day Paid] - Sales[Day Sold] )
                * CALCULATE ( SUM ( Sales[Amount Sold] ) )
        ),
        TotalAmountSold
    )&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;Owen&lt;/P&gt;</description>
    <pubDate>Wed, 05 May 2021 21:38:12 GMT</pubDate>
    <dc:creator>OwenAuger</dc:creator>
    <dc:date>2021-05-05T21:38:12Z</dc:date>
    <item>
      <title>weighted average date</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/weighted-average-date/m-p/1825784#M38755</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm working with a sales table that has three main columns: Amount sold; day sold; and day payed. I'd like to know what is the average days that I take between sell a product and be payed, but I would like as well to do a weighted average.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It was supposed to be something like this: SUMX( (Amount Sold) * (Day payed - day sold) / (Total Amount sold).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How can I do a measure that return me directly this result?&lt;/P&gt;</description>
      <pubDate>Wed, 05 May 2021 21:16:06 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/weighted-average-date/m-p/1825784#M38755</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-05-05T21:16:06Z</dc:date>
    </item>
    <item>
      <title>Re: weighted average date</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/weighted-average-date/m-p/1825801#M38758</link>
      <description>&lt;P&gt;Hi&amp;nbsp;Anonymous&lt;/LI-USER&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Yes, that's exactly the idea.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In DAX, I would write something like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Average days sold-paid =
VAR TotalAmountSold =
    SUM ( Sales[Amount Sold] )
RETURN
    DIVIDE (
        SUMX ( Sales, ( Sales[Day Paid] - Sales[Day Sold] ) * Sales[Amount Sold] ),
        TotalAmountSold
    )&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Another version that could improve performance depending on distribution of your dates, especially if you have the same pairs of dates occurring repeatedly:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Average days sold-paid =
VAR TotalAmountSold =
    SUM ( Sales[Amount Sold] )
RETURN
    DIVIDE (
        SUMX (
            SUMMARIZE ( Sales, Sales[Day Paid], Sales[Day Sold] ),
            ( Sales[Day Paid] - Sales[Day Sold] )
                * CALCULATE ( SUM ( Sales[Amount Sold] ) )
        ),
        TotalAmountSold
    )&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;Owen&lt;/P&gt;</description>
      <pubDate>Wed, 05 May 2021 21:38:12 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/weighted-average-date/m-p/1825801#M38758</guid>
      <dc:creator>OwenAuger</dc:creator>
      <dc:date>2021-05-05T21:38:12Z</dc:date>
    </item>
    <item>
      <title>Re: weighted average date</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/weighted-average-date/m-p/1828140#M38845</link>
      <description>&lt;P&gt;Thanks Bro, you were awesome! It worked perfect&lt;/P&gt;</description>
      <pubDate>Thu, 06 May 2021 16:32:18 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/weighted-average-date/m-p/1828140#M38845</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-05-06T16:32:18Z</dc:date>
    </item>
  </channel>
</rss>

