<?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: how to find the datediff between 2 table that has a indirect relationship in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/how-to-find-the-datediff-between-2-table-that-has-a-indirect/m-p/2579897#M73996</link>
    <description>&lt;P&gt;You could try&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Date diff =
var prNumber = 'PR Table'[PR Number]
var poNumber = SELECTCOLUMNS( TOPN(1,
FILTER( 'PO Table', 'PO Table'[PR Number] = prNumber),
'PO Table'[PO Date]),
"@val", 'PO Table'[PO Number])
var grnDate = SELECTCOLUMNS( TOPN(1,
FILTER( 'GRN Table', 'GRN Table'[PO Number] = poNumber),
'GRN Table'[GRN Date]),
"@val2", 'GRN Table'[GRN Date])
return DATEDIFF( 'PR Table'[PR Date], grnDate, DAY)&lt;/LI-CODE&gt;&lt;P&gt;This relies on there being only 1 entry per PO or per GRN per date. If there can be multiple entries for a given date then you will need to use another column for the sorting in the TOPN statements which is guaranteed to be unique. If necessary, you can use Power Query to generate an index column during data import&lt;/P&gt;</description>
    <pubDate>Wed, 15 Jun 2022 10:25:05 GMT</pubDate>
    <dc:creator>johnt75</dc:creator>
    <dc:date>2022-06-15T10:25:05Z</dc:date>
    <item>
      <title>how to find the datediff between 2 table that has a indirect relationship</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/how-to-find-the-datediff-between-2-table-that-has-a-indirect/m-p/2574819#M73668</link>
      <description>&lt;P&gt;Hi everyone, hope you doing well.&lt;/P&gt;&lt;P&gt;I have face some difficulties in finding the number of date difference between 2 table that has a indirect relationship.&amp;nbsp;&lt;/P&gt;&lt;P&gt;For example, PR table have a direct relationship to PO table, and PO table have a direct relationship to GRN table.&amp;nbsp;&lt;/P&gt;&lt;P&gt;how can I find out the datediff between PR date ( in PR table) and GRN Date (in GRN table).&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;thank you&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 13 Jun 2022 09:58:59 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/how-to-find-the-datediff-between-2-table-that-has-a-indirect/m-p/2574819#M73668</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-06-13T09:58:59Z</dc:date>
    </item>
    <item>
      <title>Re: how to find the datediff between 2 table that has a indirect relationship</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/how-to-find-the-datediff-between-2-table-that-has-a-indirect/m-p/2575419#M73728</link>
      <description>&lt;P&gt;If the relationships are both one-to-one then you can use the RELATED function. e.g. you could add a column to the PR table like&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Date diff = DATEDIFF('PR table'[PR date], RELATED( 'GRN table'[GRN Date]), DAY)&lt;/LI-CODE&gt;</description>
      <pubDate>Mon, 13 Jun 2022 13:56:27 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/how-to-find-the-datediff-between-2-table-that-has-a-indirect/m-p/2575419#M73728</guid>
      <dc:creator>johnt75</dc:creator>
      <dc:date>2022-06-13T13:56:27Z</dc:date>
    </item>
    <item>
      <title>Re: how to find the datediff between 2 table that has a indirect relationship</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/how-to-find-the-datediff-between-2-table-that-has-a-indirect/m-p/2578941#M73938</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="240987" data-lia-user-login="johnt75" class="lia-mention lia-mention-user"&gt;johnt75&lt;/a&gt;&amp;nbsp;,&amp;nbsp;&lt;BR /&gt;But both of the relationship is one-to-many in this case. is thre an alternative way to solve this ?&lt;/P&gt;</description>
      <pubDate>Wed, 15 Jun 2022 02:34:40 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/how-to-find-the-datediff-between-2-table-that-has-a-indirect/m-p/2578941#M73938</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-06-15T02:34:40Z</dc:date>
    </item>
    <item>
      <title>Re: how to find the datediff between 2 table that has a indirect relationship</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/how-to-find-the-datediff-between-2-table-that-has-a-indirect/m-p/2579897#M73996</link>
      <description>&lt;P&gt;You could try&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Date diff =
var prNumber = 'PR Table'[PR Number]
var poNumber = SELECTCOLUMNS( TOPN(1,
FILTER( 'PO Table', 'PO Table'[PR Number] = prNumber),
'PO Table'[PO Date]),
"@val", 'PO Table'[PO Number])
var grnDate = SELECTCOLUMNS( TOPN(1,
FILTER( 'GRN Table', 'GRN Table'[PO Number] = poNumber),
'GRN Table'[GRN Date]),
"@val2", 'GRN Table'[GRN Date])
return DATEDIFF( 'PR Table'[PR Date], grnDate, DAY)&lt;/LI-CODE&gt;&lt;P&gt;This relies on there being only 1 entry per PO or per GRN per date. If there can be multiple entries for a given date then you will need to use another column for the sorting in the TOPN statements which is guaranteed to be unique. If necessary, you can use Power Query to generate an index column during data import&lt;/P&gt;</description>
      <pubDate>Wed, 15 Jun 2022 10:25:05 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/how-to-find-the-datediff-between-2-table-that-has-a-indirect/m-p/2579897#M73996</guid>
      <dc:creator>johnt75</dc:creator>
      <dc:date>2022-06-15T10:25:05Z</dc:date>
    </item>
    <item>
      <title>Re: how to find the datediff between 2 table that has a indirect relationship</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/how-to-find-the-datediff-between-2-table-that-has-a-indirect/m-p/2581783#M74104</link>
      <description>&lt;P&gt;Hi&amp;nbsp;Anonymous&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I suggest you to create a measure to calculate the datediff between PR date and GRN date. Here I create a sample to have a test.&lt;/P&gt;
&lt;P&gt;Data model:&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;Measure:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Datediff = 
VAR _SUMMARIZE =
    SUMMARIZE (
        GRN,
        GRN[GRN Number],
        GRN[GRN date],
        "Datediff",
            VAR _PR_NUMBER =
                CALCULATE ( MAX ( PO[PR Number] ) )
            VAR _PR_DATE =
                CALCULATE ( MAX ( PR[PR date] ), FILTER ( PR, PR[PR Number] = _PR_NUMBER ) )
            RETURN
                DATEDIFF ( _PR_DATE, [GRN date], DAY )
    )
RETURN
SUMX(_SUMMARIZE,[Datediff])&lt;/LI-CODE&gt;
&lt;P&gt;Result is as below.&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;BR /&gt;Rico Zhou&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.&lt;/P&gt;</description>
      <pubDate>Thu, 16 Jun 2022 03:23:38 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/how-to-find-the-datediff-between-2-table-that-has-a-indirect/m-p/2581783#M74104</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-06-16T03:23:38Z</dc:date>
    </item>
    <item>
      <title>Re: how to find the datediff between 2 table that has a indirect relationship</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/how-to-find-the-datediff-between-2-table-that-has-a-indirect/m-p/2581786#M74105</link>
      <description>&lt;P&gt;okay, got it! thank you so much for the clarification. really appreciate that&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 16 Jun 2022 03:27:41 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/how-to-find-the-datediff-between-2-table-that-has-a-indirect/m-p/2581786#M74105</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-06-16T03:27:41Z</dc:date>
    </item>
  </channel>
</rss>

