<?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: Datediff between two inactive tables in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Datediff-between-two-inactive-tables/m-p/4334114#M172076</link>
    <description>&lt;P&gt;I forgot to add to the problem:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;We only want the datediff when the order date is from a specific category. In other words, we need a filtered Orders table.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How would we do that?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;appreciate your help!&lt;/P&gt;</description>
    <pubDate>Wed, 18 Dec 2024 03:54:01 GMT</pubDate>
    <dc:creator>Silvard</dc:creator>
    <dc:date>2024-12-18T03:54:01Z</dc:date>
    <item>
      <title>Datediff between two inactive tables</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Datediff-between-two-inactive-tables/m-p/4334106#M172075</link>
      <description>&lt;P&gt;Problem:&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;How do we create a measure that can show the historical datediff over time in a line graph using month or year as x-axis between the order date and invoice date when the two tables are only linked through a facts table and both dates have inactive relationships with the calendar table?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Setup:&lt;/P&gt;&lt;P&gt;- Facts Table linked to Orders Table via OrderId&lt;/P&gt;&lt;P&gt;- Facts Table Linked to Invoice Table via InvoiceID.&lt;/P&gt;&lt;P&gt;- Invoice date and Orders date both have inactive relationships with the Calendar table.&lt;/P&gt;</description>
      <pubDate>Wed, 18 Dec 2024 03:41:12 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Datediff-between-two-inactive-tables/m-p/4334106#M172075</guid>
      <dc:creator>Silvard</dc:creator>
      <dc:date>2024-12-18T03:41:12Z</dc:date>
    </item>
    <item>
      <title>Re: Datediff between two inactive tables</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Datediff-between-two-inactive-tables/m-p/4334114#M172076</link>
      <description>&lt;P&gt;I forgot to add to the problem:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;We only want the datediff when the order date is from a specific category. In other words, we need a filtered Orders table.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How would we do that?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;appreciate your help!&lt;/P&gt;</description>
      <pubDate>Wed, 18 Dec 2024 03:54:01 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Datediff-between-two-inactive-tables/m-p/4334114#M172076</guid>
      <dc:creator>Silvard</dc:creator>
      <dc:date>2024-12-18T03:54:01Z</dc:date>
    </item>
    <item>
      <title>Re: Datediff between two inactive tables</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Datediff-between-two-inactive-tables/m-p/4334136#M172077</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="803517" data-lia-user-login="Silvard" class="lia-mention lia-mention-user"&gt;Silvard&lt;/a&gt;&amp;nbsp; It is hard to give specific solution without representative data and desired output. Anyway, you can activate inactive relationship temporarily using USERELATIONSHIP function.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For example:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;DateDiffMeasureWithCategory = 
VAR OrderDate = CALCULATE(
    MAX(Orders[OrderDate]),
    USERELATIONSHIP(Orders[OrderDate], Calendar[Date]),
    Orders[Category] = "SpecificCategory"  -- Replace with your specific category
)
VAR InvoiceDate = CALCULATE(
    MAX(Invoices[InvoiceDate]),
    USERELATIONSHIP(Invoices[InvoiceDate], Calendar[Date])
)
RETURN
DATEDIFF(OrderDate, InvoiceDate, DAY)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;Now you can use month or year from calendar table in line visual and above similar measure.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hope this helps!!&lt;/P&gt;&lt;P&gt;If this solved your problem, please accept it as a solution and a kudos!!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best Regards,&lt;BR /&gt;Shahariar Hafiz&lt;/P&gt;</description>
      <pubDate>Wed, 18 Dec 2024 04:20:36 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Datediff-between-two-inactive-tables/m-p/4334136#M172077</guid>
      <dc:creator>shafiz_p</dc:creator>
      <dc:date>2024-12-18T04:20:36Z</dc:date>
    </item>
    <item>
      <title>Re: Datediff between two inactive tables</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Datediff-between-two-inactive-tables/m-p/4334149#M172078</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="736379" data-lia-user-login="shafiz_p" class="lia-mention lia-mention-user"&gt;shafiz_p&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thanks for your input.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm looking for the average datediff in context of the x axis (year or month) and I don't believe using MAX achieves this.&lt;/P&gt;</description>
      <pubDate>Wed, 18 Dec 2024 04:28:57 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Datediff-between-two-inactive-tables/m-p/4334149#M172078</guid>
      <dc:creator>Silvard</dc:creator>
      <dc:date>2024-12-18T04:28:57Z</dc:date>
    </item>
    <item>
      <title>Re: Datediff between two inactive tables</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Datediff-between-two-inactive-tables/m-p/4334237#M172080</link>
      <description>&lt;P&gt;Hi &lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="803517" data-lia-user-login="Silvard" class="lia-mention lia-mention-user"&gt;Silvard&lt;/a&gt;&amp;nbsp;,Thank you for reaching out to Microsoft Fabric Community Forum.&lt;/P&gt;
&lt;P&gt;Please try this modified DAX query:&lt;/P&gt;
&lt;P&gt;AverageOrderToInvoiceDiff =&lt;/P&gt;
&lt;P&gt;AVERAGEX (&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; FILTER (&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ALL ( Orders ),&amp;nbsp; -- Remove row-level filters from Orders table (but not calendar context)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Orders[Category] = "SpecificCategory"&amp;nbsp; -- Filter for a specific category&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ),&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; VAR _OrderDate =&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; CALCULATE (&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; FIRSTNONBLANK ( Orders[OrderDate], 1 ),&amp;nbsp; -- Use FIRSTNONBLANK to get order date in context&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; USERELATIONSHIP ( Orders[OrderDate], Calendar[Date] )&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; )&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; VAR _InvoiceDate =&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; CALCULATE (&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; FIRSTNONBLANK ( Invoice[InvoiceDate], 1 ),&amp;nbsp; -- Use FIRSTNONBLANK to get invoice date in context&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; USERELATIONSHIP ( Invoice[InvoiceDate], Calendar[Date] )&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; )&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; RETURN&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; DATEDIFF ( _OrderDate, _InvoiceDate, DAY )&amp;nbsp; -- Calculate the difference (use MONTH/YEAR if needed)&lt;/P&gt;
&lt;P&gt;)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The above measure will calculate the average difference between the order date and the invoice date for the specific category in the context of each time period (Month or Year).&lt;/P&gt;
&lt;P&gt;You can add year or month on x-axis and add AverageOrderToInvoiceDiff measure to y-axis. We can use a slicer for Orders[Category] to filter by a specific category.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;If this helps, please mark it ‘Accept as Solution’, so others with similar queries may find it more easily. If not, please share the details.&lt;/P&gt;</description>
      <pubDate>Wed, 18 Dec 2024 05:34:57 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Datediff-between-two-inactive-tables/m-p/4334237#M172080</guid>
      <dc:creator>v-hashadapu</dc:creator>
      <dc:date>2024-12-18T05:34:57Z</dc:date>
    </item>
    <item>
      <title>Re: Datediff between two inactive tables</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Datediff-between-two-inactive-tables/m-p/4334693#M172100</link>
      <description>&lt;P&gt;You could try this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;AverageDateDiffWithCategory =
    AVERAGEX(
        FILTER(
            Orders,
            Orders[Category] = "SpecificCategory"  -- Replace with your specific category
        ),
        [DateDiffMeasureWithCategory]
    )

Where [DateDiffMeasureWithCategory] is the measure you have created previously. Need to remove category part from the measure.&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hope this helps!!&lt;/P&gt;&lt;P&gt;If this solved your problem, please accept it as a solution and a kudos!!&lt;/P&gt;</description>
      <pubDate>Wed, 18 Dec 2024 08:40:09 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Datediff-between-two-inactive-tables/m-p/4334693#M172100</guid>
      <dc:creator>shafiz_p</dc:creator>
      <dc:date>2024-12-18T08:40:09Z</dc:date>
    </item>
    <item>
      <title>Re: Datediff between two inactive tables</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Datediff-between-two-inactive-tables/m-p/4334831#M172109</link>
      <description>&lt;P&gt;Hi there!&lt;/P&gt;&lt;P&gt;thanks for helping me try to solve this issue. I accepted it as a solution but have since realised that it's not pulling the correct results.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've asked chatgpt as well and received below response.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;have you got any other idea how to solve it?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;like I've tried to create a virtual table using selectcolumns,filter and calculatetable but unfortunately this exceeds the available resources and I never get to see if it works.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;"&lt;SPAN class=""&gt;FIRSTNONBLANK: This function returns the first value that is not blank from the specified column (in this case, Orders[OrderDate]) within the given filter context. It scans the rows one by one, from the start, and stops when it finds the first non-blank value. It does not return all values—just the first one that isn't blank.&lt;/SPAN&gt;&lt;/P&gt;&lt;P class=""&gt;&lt;SPAN class=""&gt;The 1 in FIRSTNONBLANK(Orders[OrderDate], 1): This is the expression to evaluate when determining the first non-blank value. It could be any expression, but since 1 is a constant, it is effectively irrelevant in this case. The function just checks for the first row where Orders[OrderDate] is not blank and returns that value.&lt;/SPAN&gt;&lt;/P&gt;&lt;P class=""&gt;&lt;SPAN class=""&gt;Does it stop after the first non-blank?&lt;/SPAN&gt;&lt;/P&gt;&lt;P class=""&gt;&lt;SPAN class=""&gt;Yes, it stops after finding the first non-blank value. It doesn't continue&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 18 Dec 2024 10:08:31 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Datediff-between-two-inactive-tables/m-p/4334831#M172109</guid>
      <dc:creator>Silvard</dc:creator>
      <dc:date>2024-12-18T10:08:31Z</dc:date>
    </item>
  </channel>
</rss>

