<?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: Need Help to calculate the # of days since a customer's last invoice, and later get an avg in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Need-Help-to-calculate-the-of-days-since-a-customer-s-last/m-p/2542442#M71663</link>
    <description>&lt;P&gt;Hi:&lt;/P&gt;&lt;P&gt;If you have a Date Table connected to your Fact Table(Sales Table) -then these measures should work.&lt;/P&gt;&lt;P&gt;* Table is usually the sales table. I’m using Table below..&lt;/P&gt;&lt;P&gt;Date of Last Purchase = LASTDATE(Table[Purchase Date])&lt;/P&gt;&lt;P&gt;Last Purchase Date = MAXX(ALL(Table), Table[Purchase Date])&lt;/P&gt;&lt;P&gt;Days Since Last Purchase = IF(ISBLANK( [Date of Last Purchase]), BLANK(), VALUE([Last Purchase Date] – [Date of Last Purchase]))&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Avg Days = AVERAGEX(Table, [Days Since Last Purchase])&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I hope you find this as a solution. Good luck. Thanks...&lt;/P&gt;</description>
    <pubDate>Fri, 27 May 2022 00:31:24 GMT</pubDate>
    <dc:creator>Whitewater100</dc:creator>
    <dc:date>2022-05-27T00:31:24Z</dc:date>
    <item>
      <title>Need Help to calculate the # of days since a customer's last invoice, and later get an avg</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Need-Help-to-calculate-the-of-days-since-a-customer-s-last/m-p/2542423#M71661</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I was able to create a measure for the last date serviced for each customer. However, when I try to create an AVERAGEX measure, I am not able to bring in the data i need (I think it's because I created a measure instead of a calculated column).&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My goal is to get the last invoice date for each customer, then determin how many days have gone by for each customer, then get an aggregate avg # days not invoiced to summarize.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Would you have any advice?&lt;/P&gt;</description>
      <pubDate>Thu, 26 May 2022 23:59:31 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Need-Help-to-calculate-the-of-days-since-a-customer-s-last/m-p/2542423#M71661</guid>
      <dc:creator>OCBB_SFAFPandA</dc:creator>
      <dc:date>2022-05-26T23:59:31Z</dc:date>
    </item>
    <item>
      <title>Re: Need Help to calculate the # of days since a customer's last invoice, and later get an avg</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Need-Help-to-calculate-the-of-days-since-a-customer-s-last/m-p/2542442#M71663</link>
      <description>&lt;P&gt;Hi:&lt;/P&gt;&lt;P&gt;If you have a Date Table connected to your Fact Table(Sales Table) -then these measures should work.&lt;/P&gt;&lt;P&gt;* Table is usually the sales table. I’m using Table below..&lt;/P&gt;&lt;P&gt;Date of Last Purchase = LASTDATE(Table[Purchase Date])&lt;/P&gt;&lt;P&gt;Last Purchase Date = MAXX(ALL(Table), Table[Purchase Date])&lt;/P&gt;&lt;P&gt;Days Since Last Purchase = IF(ISBLANK( [Date of Last Purchase]), BLANK(), VALUE([Last Purchase Date] – [Date of Last Purchase]))&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Avg Days = AVERAGEX(Table, [Days Since Last Purchase])&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I hope you find this as a solution. Good luck. Thanks...&lt;/P&gt;</description>
      <pubDate>Fri, 27 May 2022 00:31:24 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Need-Help-to-calculate-the-of-days-since-a-customer-s-last/m-p/2542442#M71663</guid>
      <dc:creator>Whitewater100</dc:creator>
      <dc:date>2022-05-27T00:31:24Z</dc:date>
    </item>
    <item>
      <title>Re: Need Help to calculate the # of days since a customer's last invoice, and later get an avg</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Need-Help-to-calculate-the-of-days-since-a-customer-s-last/m-p/2542445#M71664</link>
      <description>&lt;P&gt;Hi Again:&lt;/P&gt;&lt;P&gt;If you need a DAX Date Table, I will paste code below. You'll want to go to MODELING&amp;gt; NEW TABLE&lt;/P&gt;&lt;P&gt;after you do this, then mark as a date table(date field) and create a realtionship with your sales/fact table on date to purchase date.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Dates =&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;-- Specify a start date and end date&lt;/P&gt;&lt;P&gt;VAR StartDate = Date(2021,1,1)&lt;/P&gt;&lt;P&gt;VAR EndDate = Today() + 243&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;VAR FiscalMonthEnd = 12&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;-- Generate a base table of dates&lt;/P&gt;&lt;P&gt;VAR BaseTable = Calendar(StartDate, EndDate)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;-- Add the Year for each individual date&lt;/P&gt;&lt;P&gt;VAR Years = ADDCOLUMNS(BaseTable,"Year",YEAR([Date]))&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;-- Add the calendar month and other month related data for each date&lt;/P&gt;&lt;P&gt;VAR Months = ADDCOLUMNS(&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Years,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; "Month",MONTH([Date]),&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; "Year and Month Number",FORMAT([Date],"YYYY-MM"),&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; "Year and Month Name",FORMAT([Date],"YYYY-MMM"),&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; "Fiscal Year", IF( FiscalMonthEnd = 12, YEAR([Date]), IF( MONTH([DATE]) &amp;lt;= FiscalMonthEnd, YEAR([DATE])-1, YEAR([Date]))),&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; "Fiscal Month", IF( FiscalMonthEnd = 12, MONTH([Date]),&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; IF( MONTH([Date]) &amp;lt;= FiscalMonthEnd, FiscalMonthEnd + MONTH([Date]), MONTH([Date]) - FiscalMonthEnd))&lt;/P&gt;&lt;P&gt;)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;-- Add the Quarter and other quarter related data for each date&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;VAR Quarters = ADDCOLUMNS(&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Months,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; "Quarter",ROUNDUP(MONTH([Date])/3,0),&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; "Year and Quarter",[Year] &amp;amp; "-Q" &amp;amp; ROUNDUP(MONTH([Date])/3,0))&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;-- Add the Day and other day related data for each date&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;VAR Days = ADDCOLUMNS(&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Quarters,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; "Day",DAY([Date]),&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; "Day Name",FORMAT([Date],"DDDD"),&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; "Day Of Week",WEEKDAY([Date]),&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; "Day Of Year", DATEDIFF (DATE(YEAR([Date]),1,1), [Date], DAY) + 1)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;-- Add the Week (assuming each week starts on a Sunday) and other week related data for each date&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;VAR Weeks = ADDCOLUMNS(&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Days,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; "Week Of Month (Sunday)",INT((DAY([Date])-1)/7)+1,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; "Week of Year (Sunday)",WEEKNUM([Date],1),&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; "Year and Week (Sunday)",[Year] &amp;amp; "-W" &amp;amp; WEEKNUM([Date],1))&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;-- Add an 'Is Working Day' column which will be true for all days but Saturday and Sunday.&lt;/P&gt;&lt;P&gt;var WorkingDays = ADDCOLUMNS(&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Weeks,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; "Is Working Day", NOT WEEKDAY( [Date] ) IN {1,7})&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;RETURN WorkingDays&lt;/P&gt;</description>
      <pubDate>Fri, 27 May 2022 00:33:34 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Need-Help-to-calculate-the-of-days-since-a-customer-s-last/m-p/2542445#M71664</guid>
      <dc:creator>Whitewater100</dc:creator>
      <dc:date>2022-05-27T00:33:34Z</dc:date>
    </item>
    <item>
      <title>Re: Need Help to calculate the # of days since a customer's last invoice, and later get an avg</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Need-Help-to-calculate-the-of-days-since-a-customer-s-last/m-p/2542452#M71665</link>
      <description>&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Fri, 27 May 2022 02:18:53 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Need-Help-to-calculate-the-of-days-since-a-customer-s-last/m-p/2542452#M71665</guid>
      <dc:creator>OCBB_SFAFPandA</dc:creator>
      <dc:date>2022-05-27T02:18:53Z</dc:date>
    </item>
  </channel>
</rss>

