<?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 Calculate Average Days for First Order (For All Customers) in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-Average-Days-for-First-Order-For-All-Customers/m-p/2854052#M91643</link>
    <description>&lt;P&gt;Hi everyone,&lt;BR /&gt;&lt;BR /&gt;I am having troubles creating this measure in Power BI. The dataset I am connected to is DirectQuery. Please see image below for reference.&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;I want to create a measure which and display it on card visual, showing average days taken to place first order (taking into account order dates for only Order types A and B). Basically this will be Datediff(Minimum Order Date - Cust Date Created).&lt;BR /&gt;And then display on number card Average number of days taken for all customers to place first order (again, only for types A and B)&lt;BR /&gt;&lt;BR /&gt;I have been stuck on this for quite some time and have tried various approaches but the results are no way closer to what I want to achieve.&lt;BR /&gt;&lt;BR /&gt;Any help on this would be appreciated. In bit of an urgency. Please let me know if I can add anything on this.&lt;BR /&gt;&lt;BR /&gt;Thanks in Advance&lt;BR /&gt;&lt;BR /&gt;Kind Regards&lt;/P&gt;</description>
    <pubDate>Thu, 20 Oct 2022 15:38:03 GMT</pubDate>
    <dc:creator>PBI_Member_01</dc:creator>
    <dc:date>2022-10-20T15:38:03Z</dc:date>
    <item>
      <title>Calculate Average Days for First Order (For All Customers)</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-Average-Days-for-First-Order-For-All-Customers/m-p/2854052#M91643</link>
      <description>&lt;P&gt;Hi everyone,&lt;BR /&gt;&lt;BR /&gt;I am having troubles creating this measure in Power BI. The dataset I am connected to is DirectQuery. Please see image below for reference.&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;I want to create a measure which and display it on card visual, showing average days taken to place first order (taking into account order dates for only Order types A and B). Basically this will be Datediff(Minimum Order Date - Cust Date Created).&lt;BR /&gt;And then display on number card Average number of days taken for all customers to place first order (again, only for types A and B)&lt;BR /&gt;&lt;BR /&gt;I have been stuck on this for quite some time and have tried various approaches but the results are no way closer to what I want to achieve.&lt;BR /&gt;&lt;BR /&gt;Any help on this would be appreciated. In bit of an urgency. Please let me know if I can add anything on this.&lt;BR /&gt;&lt;BR /&gt;Thanks in Advance&lt;BR /&gt;&lt;BR /&gt;Kind Regards&lt;/P&gt;</description>
      <pubDate>Thu, 20 Oct 2022 15:38:03 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-Average-Days-for-First-Order-For-All-Customers/m-p/2854052#M91643</guid>
      <dc:creator>PBI_Member_01</dc:creator>
      <dc:date>2022-10-20T15:38:03Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate Average Days for First Order (For All Customers)</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-Average-Days-for-First-Order-For-All-Customers/m-p/2854094#M91647</link>
      <description>&lt;P&gt;You can try this measure&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;AverageDaysTakenForFirstOrderForA&amp;amp;B =&lt;/P&gt;&lt;P&gt;DIVIDE (&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; SUMX (&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; FILTER ( tableOfYourValues, orderType = "A" || orderType = "B" ),&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; timeToFirstOrder&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; ),&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; COUNTROWS ( FILTER ( tableOfYourValues, orderType = "A" || orderType = "B" ) )&lt;/P&gt;&lt;P&gt;)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 20 Oct 2022 16:13:33 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-Average-Days-for-First-Order-For-All-Customers/m-p/2854094#M91647</guid>
      <dc:creator>Karthikstark</dc:creator>
      <dc:date>2022-10-20T16:13:33Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate Average Days for First Order (For All Customers)</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-Average-Days-for-First-Order-For-All-Customers/m-p/2854129#M91651</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="435045" data-lia-user-login="PBI_Member_01" class="lia-mention lia-mention-user"&gt;PBI_Member_01&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;please try&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="javascript"&gt;Days To First Order =
VAR DateCreated =
    MAX ( CUSTOMER[Cust Date Created] )
RETURN
    AVERAGEX (
        VALUES ( CUSTOMER[Cust ID] ),
        VAR FirstOrderDate =
            CALCULATE (
                MIN ( ORDERS[Order Date] ),
                REMOVEFILTERS (),
                VALUES ( CUSTOMER[Cust ID] ),
                ORDERS[Order Type] IN { "A", "B" }
            )
        RETURN
            DATEDIFF ( DateCreated, FirstOrderDate, DAY )
    )&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 20 Oct 2022 16:34:41 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-Average-Days-for-First-Order-For-All-Customers/m-p/2854129#M91651</guid>
      <dc:creator>tamerj1</dc:creator>
      <dc:date>2022-10-20T16:34:41Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate Average Days for First Order (For All Customers)</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-Average-Days-for-First-Order-For-All-Customers/m-p/2854153#M91655</link>
      <description>&lt;P&gt;Thank you for your suggestion on this, I tried but this is not giving the correct values.&lt;BR /&gt;&lt;BR /&gt;What I want is, From the time when a customer was created (Information in &lt;STRONG&gt;Table A&lt;/STRONG&gt;, using &lt;STRONG&gt;Cust Date Created&lt;/STRONG&gt;) till the time (&lt;STRONG&gt;days&lt;/STRONG&gt;) customer placed their first order (Information in &lt;STRONG&gt;Table&lt;/STRONG&gt; &lt;STRONG&gt;B&lt;/STRONG&gt;, using &lt;STRONG&gt;Order Date)&lt;/STRONG&gt; for Types A and B (basically filter minimum order date for only order types &lt;STRONG&gt;A&lt;/STRONG&gt; and &lt;STRONG&gt;B&lt;/STRONG&gt;), have this calculated for every cust ID in Table A (something like &lt;STRONG&gt;DATEDIFF(Cust Date Created,Order Date,DAY) &lt;/STRONG&gt;)&lt;BR /&gt;&lt;BR /&gt;And then for report, display on card visual, the Average of this value, which will basically give a single number representing on average, it takes " X " number of days for customer to place order.&lt;BR /&gt;&lt;BR /&gt;Hope this brings some clarity and if not, let me know if I can add anything further on this.&lt;BR /&gt;&lt;BR /&gt;Thanks and Regards&lt;/P&gt;</description>
      <pubDate>Thu, 20 Oct 2022 16:53:00 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-Average-Days-for-First-Order-For-All-Customers/m-p/2854153#M91655</guid>
      <dc:creator>PBI_Member_01</dc:creator>
      <dc:date>2022-10-20T16:53:00Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate Average Days for First Order (For All Customers)</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-Average-Days-for-First-Order-For-All-Customers/m-p/2854206#M91662</link>
      <description>&lt;P&gt;Hi &lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="317289" data-lia-user-login="tamerj1" class="lia-mention lia-mention-user"&gt;tamerj1&lt;/a&gt; ,&lt;BR /&gt;&lt;BR /&gt;Thank you for your quick response on this. I am currently implementing this and will update you shortly on this.&lt;BR /&gt;&lt;BR /&gt;Can you please confirm if I can actually test this out, for instance in a table matrix against each customer ID,if the days being calculated are correct for every customer and then the actual average for all customers?&lt;BR /&gt;&lt;BR /&gt;Many thanks in advance&lt;BR /&gt;&lt;BR /&gt;Regards&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 20 Oct 2022 17:29:22 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-Average-Days-for-First-Order-For-All-Customers/m-p/2854206#M91662</guid>
      <dc:creator>PBI_Member_01</dc:creator>
      <dc:date>2022-10-20T17:29:22Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate Average Days for First Order (For All Customers)</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-Average-Days-for-First-Order-For-All-Customers/m-p/2854270#M91668</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="435045" data-lia-user-login="PBI_Member_01" class="lia-mention lia-mention-user"&gt;PBI_Member_01&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I didn't test to be honest but it is is designed to work in both table visual sliced by Cust ID as well as in a card visual.&amp;nbsp;&lt;BR /&gt;please test and let me know if anything goes wrong.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 20 Oct 2022 18:20:02 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-Average-Days-for-First-Order-For-All-Customers/m-p/2854270#M91668</guid>
      <dc:creator>tamerj1</dc:creator>
      <dc:date>2022-10-20T18:20:02Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate Average Days for First Order (For All Customers)</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-Average-Days-for-First-Order-For-All-Customers/m-p/2854373#M91672</link>
      <description>&lt;P&gt;Hi &lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="317289" data-lia-user-login="tamerj1" class="lia-mention lia-mention-user"&gt;tamerj1&lt;/a&gt; ,&lt;BR /&gt;&lt;BR /&gt;Thank you for your help on this one. I am surprised you didn't manage to test this one and yet you have come up with this elegant solution. This is very close to what I want to achieve.&lt;BR /&gt;&lt;BR /&gt;So here is my feedback on this after some testing, it does calculate the day to first order correctly for each row, but I think it is not calculating the Average correctly. Please take a look at the screenshot below:&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;So the values that you can see 21, 12, 24, 2, and 1 are correctly calculated for the respective cust IDs. However, the average does not seem to be correct and looks off. Shouldn't the average be 12 in this case?&lt;BR /&gt;&lt;BR /&gt;This has been of great help so far. Would really appreciate if you can look into this.&lt;BR /&gt;&lt;BR /&gt;Thanks &amp;amp; Kind Regards&lt;/P&gt;</description>
      <pubDate>Thu, 20 Oct 2022 19:53:00 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-Average-Days-for-First-Order-For-All-Customers/m-p/2854373#M91672</guid>
      <dc:creator>PBI_Member_01</dc:creator>
      <dc:date>2022-10-20T19:53:00Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate Average Days for First Order (For All Customers)</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-Average-Days-for-First-Order-For-All-Customers/m-p/2854884#M91718</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="435045" data-lia-user-login="PBI_Member_01" class="lia-mention lia-mention-user"&gt;PBI_Member_01&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;please try&lt;/P&gt;
&lt;LI-CODE lang="javascript"&gt;Days To First Order =
VAR DateCreated =
    MAX ( CUSTOMER[Cust Date Created] )
RETURN
    AVERAGEX (
        VALUES ( CUSTOMER[Cust ID] ),
        VAR FirstOrderDate =
            CALCULATE (
                MIN ( ORDERS[Order Date] ),
                ALLEXCEPT ( CUSTOMER, CUSTOMER[Cust ID] ),
                ALL ( ORDERS ),
                ORDERS[Order Type] IN { "A", "B" }
            )
        RETURN
            DATEDIFF ( DateCreated, FirstOrderDate, DAY )
    )&lt;/LI-CODE&gt;</description>
      <pubDate>Fri, 21 Oct 2022 05:19:30 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-Average-Days-for-First-Order-For-All-Customers/m-p/2854884#M91718</guid>
      <dc:creator>tamerj1</dc:creator>
      <dc:date>2022-10-21T05:19:30Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate Average Days for First Order (For All Customers)</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-Average-Days-for-First-Order-For-All-Customers/m-p/2855080#M91731</link>
      <description>&lt;P&gt;Hi &lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="317289" data-lia-user-login="tamerj1" class="lia-mention lia-mention-user"&gt;tamerj1&lt;/a&gt; ,&lt;BR /&gt;&lt;BR /&gt;I tried the above solution but now it is going completely off even on individual customer level. Please have a look at image below:&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;So as opposed to the correct values of 21, 12, 24, 2, and 1 which I was getting before by using your calculation, now even those values are off.&lt;BR /&gt;&lt;BR /&gt;Can you please take a look at this again?&lt;BR /&gt;&lt;BR /&gt;Highly appreciate you putting your time and effort on this.&lt;BR /&gt;&lt;BR /&gt;Thanks and Regards&lt;/P&gt;</description>
      <pubDate>Fri, 21 Oct 2022 06:53:35 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-Average-Days-for-First-Order-For-All-Customers/m-p/2855080#M91731</guid>
      <dc:creator>PBI_Member_01</dc:creator>
      <dc:date>2022-10-21T06:53:35Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate Average Days for First Order (For All Customers)</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-Average-Days-for-First-Order-For-All-Customers/m-p/2855153#M91737</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="435045" data-lia-user-login="PBI_Member_01" class="lia-mention lia-mention-user"&gt;PBI_Member_01&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;ok, let's go 2 steps backwards and try the following. Let's see how it behaves.&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="javascript"&gt;Days To First Order =
VAR DateCreated =
    MAX ( CUSTOMER[Cust Date Created] )
RETURN
    AVERAGEX (
        VALUES ( CUSTOMER[Cust ID] ),
        VAR FirstOrderDate =
            CALCULATE ( MIN ( ORDERS[Order Date] ), ORDERS[Order Type] IN { "A", "B" } )
        RETURN
            DATEDIFF ( DateCreated, FirstOrderDate, DAY )
    )&lt;/LI-CODE&gt;</description>
      <pubDate>Fri, 21 Oct 2022 07:28:38 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-Average-Days-for-First-Order-For-All-Customers/m-p/2855153#M91737</guid>
      <dc:creator>tamerj1</dc:creator>
      <dc:date>2022-10-21T07:28:38Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate Average Days for First Order (For All Customers)</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-Average-Days-for-First-Order-For-All-Customers/m-p/2855990#M91802</link>
      <description>&lt;P&gt;Hi &lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="317289" data-lia-user-login="tamerj1" class="lia-mention lia-mention-user"&gt;tamerj1&lt;/a&gt; ,&lt;BR /&gt;&lt;BR /&gt;Okay so now the individual numbers are back to correct values, but the average still seems to be an issue. Please see the image below:&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Thank you once again for your input on this.&lt;BR /&gt;&lt;BR /&gt;Kind Regards&lt;/P&gt;</description>
      <pubDate>Fri, 21 Oct 2022 15:30:13 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-Average-Days-for-First-Order-For-All-Customers/m-p/2855990#M91802</guid>
      <dc:creator>PBI_Member_01</dc:creator>
      <dc:date>2022-10-21T15:30:13Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate Average Days for First Order (For All Customers)</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-Average-Days-for-First-Order-For-All-Customers/m-p/2856095#M91807</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="435045" data-lia-user-login="PBI_Member_01" class="lia-mention lia-mention-user"&gt;PBI_Member_01&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Ok I hope this will work&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="javascript"&gt;Days To First Order =
AVERAGEX (
    VALUES ( CUSTOMER[Cust ID] ),
    VAR DateCreated =
        CALCULATE ( MAX ( CUSTOMER[Cust Date Created] ) )
    VAR FirstOrderDate =
        CALCULATE ( MIN ( ORDERS[Order Date] ), ORDERS[Order Type] IN { "A", "B" } )
    RETURN
        DATEDIFF ( DateCreated, FirstOrderDate, DAY )
)&lt;/LI-CODE&gt;</description>
      <pubDate>Fri, 21 Oct 2022 16:54:22 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-Average-Days-for-First-Order-For-All-Customers/m-p/2856095#M91807</guid>
      <dc:creator>tamerj1</dc:creator>
      <dc:date>2022-10-21T16:54:22Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate Average Days for First Order (For All Customers)</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-Average-Days-for-First-Order-For-All-Customers/m-p/2856120#M91810</link>
      <description>&lt;P&gt;Hi &lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="317289" data-lia-user-login="tamerj1" class="lia-mention lia-mention-user"&gt;tamerj1&lt;/a&gt; ,&lt;BR /&gt;&lt;BR /&gt;Just tried this and yes this works perfectly well !&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Thank you for your amazing support on this !&lt;BR /&gt;&lt;BR /&gt;Regards&lt;/P&gt;</description>
      <pubDate>Fri, 21 Oct 2022 17:29:02 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-Average-Days-for-First-Order-For-All-Customers/m-p/2856120#M91810</guid>
      <dc:creator>PBI_Member_01</dc:creator>
      <dc:date>2022-10-21T17:29:02Z</dc:date>
    </item>
  </channel>
</rss>

