<?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: Average Customer Return Time in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Average-Customer-Return-Time/m-p/2885433#M93513</link>
    <description>&lt;P&gt;Addendum;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;average_orderTime also has to be yellow, this value is not calculated right now!&lt;/P&gt;</description>
    <pubDate>Fri, 04 Nov 2022 11:10:47 GMT</pubDate>
    <dc:creator>Milan_TBC</dc:creator>
    <dc:date>2022-11-04T11:10:47Z</dc:date>
    <item>
      <title>Average Customer Return Time</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Average-Customer-Return-Time/m-p/2883287#M93401</link>
      <description>&lt;P&gt;Hi,&lt;BR /&gt;&lt;BR /&gt;I want to calculate the average return time of my customers over time.&amp;nbsp;&lt;BR /&gt;I have a table with general data such as Cust_ID, and order_date per order.&amp;nbsp;&lt;BR /&gt;Right now i have general calculations based on first_order and last_order, however this doesn't cover all averages, since some customers have 10+ orders.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there a way to calculate the average time between orders? Using the regular DATE commands (DATEDIFF, DATESBETWEEN, etc,), i run into problems since most of them only accept two dates, not more.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance!&lt;/P&gt;</description>
      <pubDate>Thu, 03 Nov 2022 15:17:39 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Average-Customer-Return-Time/m-p/2883287#M93401</guid>
      <dc:creator>Milan_TBC</dc:creator>
      <dc:date>2022-11-03T15:17:39Z</dc:date>
    </item>
    <item>
      <title>Re: Average Customer Return Time</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Average-Customer-Return-Time/m-p/2884282#M93441</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="466479" data-lia-user-login="Milan_TBC" class="lia-mention lia-mention-user"&gt;Milan_TBC&lt;/a&gt;,&amp;nbsp; A new column&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Diff =&lt;/P&gt;
&lt;P&gt;var _max&amp;nbsp; = maxx(filter(Table, [Customer] = earlier([Customer]) &amp;amp;&amp;amp; [Order date] &amp;lt; earlier({order date]) ) , [Order Date])&lt;/P&gt;
&lt;P&gt;return&lt;/P&gt;
&lt;P&gt;datediff(_max, [Order date], day)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then you can take AVg of this column&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Or move this in a Meausure&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;AverageX(Table,&lt;/P&gt;
&lt;P&gt;var _max&amp;nbsp; = maxx(filter(Table, [Customer] = earlier([Customer]) &amp;amp;&amp;amp; [Order date] &amp;lt; earlier({order date]) ) , [Order Date])&lt;/P&gt;
&lt;P&gt;return&lt;/P&gt;
&lt;P&gt;datediff(_max, [Order date], day) )&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Earlier, I should have known Earlier: &lt;A href="https://youtu.be/CVW6YwvHHi8" target="_blank"&gt;https://youtu.be/CVW6YwvHHi8&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 04 Nov 2022 02:10:04 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Average-Customer-Return-Time/m-p/2884282#M93441</guid>
      <dc:creator>amitchandak</dc:creator>
      <dc:date>2022-11-04T02:10:04Z</dc:date>
    </item>
    <item>
      <title>Re: Average Customer Return Time</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Average-Customer-Return-Time/m-p/2884552#M93475</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="466479" data-lia-user-login="Milan_TBC" class="lia-mention lia-mention-user"&gt;Milan_TBC&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;Could you please provide some&amp;nbsp;&lt;STRONG&gt;sample data&lt;/STRONG&gt;&amp;nbsp;in your order table (&lt;STRONG&gt;&lt;EM&gt;exclude&amp;nbsp;&lt;/EM&gt;&lt;/STRONG&gt;&lt;EM&gt;&lt;STRONG&gt;sensitive&amp;nbsp;&lt;/STRONG&gt;&lt;/EM&gt;&lt;STRONG&gt;&lt;EM&gt;data&lt;/EM&gt;&lt;/STRONG&gt;) with&amp;nbsp;&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;Text&lt;/STRONG&gt;&amp;nbsp;&lt;/FONT&gt;format and your&amp;nbsp;&lt;STRONG&gt;expected result&lt;/STRONG&gt;&amp;nbsp;with backend logic and special examples. For example: the data in the below table, which value you want to get? And How do you calculate it?&amp;nbsp;&amp;nbsp;&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;It is better&lt;/STRONG&gt;&amp;nbsp;&lt;/FONT&gt;if you can share a&amp;nbsp;&lt;FONT color="#008000"&gt;&lt;STRONG&gt;simplified&lt;/STRONG&gt;&amp;nbsp;&lt;/FONT&gt;pbix file. You can refer the following link to upload the file to the community. Thank you.&lt;/P&gt;
&lt;P&gt;&lt;A href="https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fcommunity.powerbi.com%2Ft5%2FDesktop%2FHow-to-upload-PBI-in-Community%2Fm-p%2F1672886&amp;amp;data=04%7C01%7Cv-yiruan%40microsoft.com%7C4f580813734d4a8355b008da16f6e91a%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637847547341062885%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&amp;amp;sdata=YJvujige2YITXKbKED9JieQm5LBdf%2F3IYPM4ggdiijQ%3D&amp;amp;reserved=0" target="_blank" rel="nofollow noopener noreferrer"&gt;How to upload PBI in Community&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;Best Regards&lt;/P&gt;</description>
      <pubDate>Fri, 04 Nov 2022 05:39:42 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Average-Customer-Return-Time/m-p/2884552#M93475</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-11-04T05:39:42Z</dc:date>
    </item>
    <item>
      <title>Re: Average Customer Return Time</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Average-Customer-Return-Time/m-p/2885429#M93511</link>
      <description>&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The following table is an indication for what is needed, where the yellow values are what i'm looking for!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="148838" data-lia-user-login="amitchandak" class="lia-mention lia-mention-user"&gt;amitchandak&lt;/a&gt;&amp;nbsp;Right now your solution does not seem to work, i recieve syntax errors, mainly "&lt;SPAN&gt;&amp;lt; earlier({order date]) )" does not seem to function correctly.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Looking forward to any other solutions, Thanks in advance!&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 04 Nov 2022 11:09:47 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Average-Customer-Return-Time/m-p/2885429#M93511</guid>
      <dc:creator>Milan_TBC</dc:creator>
      <dc:date>2022-11-04T11:09:47Z</dc:date>
    </item>
    <item>
      <title>Re: Average Customer Return Time</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Average-Customer-Return-Time/m-p/2885433#M93513</link>
      <description>&lt;P&gt;Addendum;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;average_orderTime also has to be yellow, this value is not calculated right now!&lt;/P&gt;</description>
      <pubDate>Fri, 04 Nov 2022 11:10:47 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Average-Customer-Return-Time/m-p/2885433#M93513</guid>
      <dc:creator>Milan_TBC</dc:creator>
      <dc:date>2022-11-04T11:10:47Z</dc:date>
    </item>
    <item>
      <title>Re: Average Customer Return Time</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Average-Customer-Return-Time/m-p/2888772#M93713</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;A href="https://community.powerbi.com/t5/user/viewprofilepage/user-id/333644" target="_blank"&gt;@Manal_Edd&lt;/A&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;I created a sample pbix file(&lt;STRONG&gt;&lt;SPAN&gt;see attachment&lt;/SPAN&gt;&lt;/STRONG&gt;) for you, please check whether that is what you want.&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;1. Create two measures as below&lt;/SPAN&gt;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Datediff = 
VAR _selcust =
    SELECTEDVALUE ( 'Table'[lead_customer_id] )
VAR _seldate =
    SELECTEDVALUE ( 'Table'[closed_at] )
VAR _predate =
    CALCULATE (
        MAX ( 'Table'[closed_at] ),
        FILTER (
            ALLSELECTED ( 'Table' ),
            'Table'[lead_customer_id] = _selcust
                &amp;amp;&amp;amp; 'Table'[closed_at] &amp;lt; _seldate
        )
    )
RETURN
    DATEDIFF ( _predate, _seldate, DAY )&lt;/LI-CODE&gt;&lt;LI-CODE lang="markup"&gt;average_orderTime = 
VAR _selcustid =
    SELECTEDVALUE ( 'Table'[lead_customer_id] )
VAR _count =
    CALCULATE (
        COUNT ( 'Table'[lead_customer_id] ),
        FILTER ( ALLSELECTED ( 'Table' ), 'Table'[lead_customer_id] = _selcustid )
    )
VAR _sum =
    SUMX (
        FILTER ( ALLSELECTED ( 'Table' ), 'Table'[lead_customer_id] = _selcustid ),
        [Datediff]
    )
RETURN
    IF (
        ISBLANK ( [Datediff] ),
        0,
        IF ( _count = 1, _sum, ROUND ( DIVIDE ( _sum, _count - 1 ), 0 ) )
    )&lt;/LI-CODE&gt;
&lt;P&gt;2.&amp;nbsp;&lt;SPAN&gt;Create a table visual&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If the above one can't help you get the desired result, please provide more&amp;nbsp;&lt;STRONG&gt;sample data&lt;/STRONG&gt;&amp;nbsp;in your tables (&lt;STRONG&gt;&lt;EM&gt;exclude&amp;nbsp;&lt;/EM&gt;&lt;/STRONG&gt;&lt;EM&gt;&lt;STRONG&gt;sensitive&amp;nbsp;&lt;/STRONG&gt;&lt;/EM&gt;&lt;STRONG&gt;&lt;EM&gt;data&lt;/EM&gt;&lt;/STRONG&gt;) with&amp;nbsp;&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;Text&lt;/STRONG&gt;&amp;nbsp;&lt;/FONT&gt;format and your&amp;nbsp;&lt;STRONG&gt;expected result&lt;/STRONG&gt;&amp;nbsp;with backend logic and special examples.&amp;nbsp;&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;It is better&lt;/STRONG&gt;&amp;nbsp;&lt;/FONT&gt;if you can share a&amp;nbsp;&lt;FONT color="#008000"&gt;&lt;STRONG&gt;simplified&lt;/STRONG&gt;&amp;nbsp;&lt;/FONT&gt;pbix file. You can refer the following link to upload the file to the community. Thank you.&lt;/P&gt;
&lt;P&gt;&lt;A href="https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fcommunity.powerbi.com%2Ft5%2FDesktop%2FHow-to-upload-PBI-in-Community%2Fm-p%2F1672886&amp;amp;data=04%7C01%7Cv-yiruan%40microsoft.com%7C4f580813734d4a8355b008da16f6e91a%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637847547341062885%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&amp;amp;sdata=YJvujige2YITXKbKED9JieQm5LBdf%2F3IYPM4ggdiijQ%3D&amp;amp;reserved=0" target="_blank" rel="nofollow noopener noreferrer"&gt;How to upload PBI in Community&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;Best Regards&lt;/P&gt;</description>
      <pubDate>Mon, 07 Nov 2022 09:14:50 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Average-Customer-Return-Time/m-p/2888772#M93713</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-11-07T09:14:50Z</dc:date>
    </item>
    <item>
      <title>Re: Average Customer Return Time</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Average-Customer-Return-Time/m-p/2889219#M93733</link>
      <description>&lt;P&gt;Thanks a lot!&lt;/P&gt;</description>
      <pubDate>Mon, 07 Nov 2022 12:17:09 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Average-Customer-Return-Time/m-p/2889219#M93733</guid>
      <dc:creator>Milan_TBC</dc:creator>
      <dc:date>2022-11-07T12:17:09Z</dc:date>
    </item>
  </channel>
</rss>

