<?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: Comparing dates cross table in Power Query</title>
    <link>https://community.fabric.microsoft.com/t5/Power-Query/Comparing-dates-cross-table/m-p/2338764#M69737</link>
    <description>&lt;P&gt;Hi&amp;nbsp;Anonymous&lt;/LI-USER&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;Have created a sample table query that you can try it:&lt;/P&gt;
&lt;P&gt;BuyOrder table:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlTSUTIyMDLUNzTQN7JUMLEysbQyMVUI8FWK1YlWMkKVNbUyNLQyMoTJGuOVNcEmawGTNcUia2wElo0FAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [BuyOrderId = _t, CreatedAt = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"BuyOrderId", Int64.Type}, {"CreatedAt", type datetime}}),
    #"Merged Queries" = Table.NestedJoin(#"Changed Type", {"BuyOrderId"}, BuyOrderRow, {"BuyOrderId"}, "BuyOrderRow", JoinKind.LeftOuter),
    #"Expanded BuyOrderRow" = Table.ExpandTableColumn(#"Merged Queries", "BuyOrderRow", {"ExpectedDeliverydate"}, {"ExpectedDeliverydate"}),
    #"Added Custom" = Table.AddColumn(#"Expanded BuyOrderRow", "Confirmed", each if [ExpectedDeliverydate] &amp;lt;&amp;gt; null and [ExpectedDeliverydate] &amp;lt;&amp;gt; [CreatedAt] then 1 else 0,Int64.Type),
    #"Added Custom1" = Table.AddColumn(#"Added Custom", "HourDiff", each if Number.RoundDown(Duration.Days(Duration.From([ExpectedDeliverydate]-[CreatedAt]))) * 24+ Duration.Hours(Duration.From([ExpectedDeliverydate]-[CreatedAt])) - 48 &amp;gt; 72 then 1 else 0, Int64.Type),
    #"Replaced Errors" = Table.ReplaceErrorValues(#"Added Custom1", {{"HourDiff", 0}}),
    #"Filtered Rows" = Table.SelectRows(#"Replaced Errors", each ([Confirmed] = 1) and ([HourDiff] = 1)),
    #"Removed Columns" = Table.RemoveColumns(#"Filtered Rows",{"ExpectedDeliverydate", "Confirmed", "HourDiff"})
in
    #"Removed Columns"&lt;/LI-CODE&gt;
&lt;P&gt;BuyOrderRow table:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlTSUTIyMDLUNzTQN7JUMLEysbQyMVUI8FWK1YlWMgLKghnGcGVG+sYKhkZWBgZApOAIUWYClzXUNzLDkDZFlkaVjQUA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [BuyOrderId = _t, ExpectedDeliverydate = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"BuyOrderId", Int64.Type}, {"ExpectedDeliverydate", type datetime}})
in
    #"Changed Type"&lt;/LI-CODE&gt;
&lt;P&gt;&lt;img /&gt;&lt;img /&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;BR /&gt;Community Support Team _ Yingjie Li&lt;/P&gt;</description>
    <pubDate>Tue, 15 Feb 2022 07:07:05 GMT</pubDate>
    <dc:creator>v-yingjl</dc:creator>
    <dc:date>2022-02-15T07:07:05Z</dc:date>
    <item>
      <title>Comparing dates cross table</title>
      <link>https://community.fabric.microsoft.com/t5/Power-Query/Comparing-dates-cross-table/m-p/2331344#M69479</link>
      <description>&lt;H1&gt;Cross Table comparing date&lt;/H1&gt;&lt;P&gt;For a project, i'd like to check the difference between dates. I want the answer in hours and hours in the weekend shouldn't count.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It's for orderstatus checking. I'd like to know if my supplier is on time. therefor i'd like to know if they confirmed my order.&lt;/P&gt;&lt;P&gt;An order is confirmed when the BuyOrderRow[ExpectedDeliverydate] isn't blank or isn't equal to the Order[CreatedAt].&amp;nbsp;&lt;/P&gt;&lt;P&gt;I only want the orders that are older than 72hours. BuyOrder[CreatedAt] &amp;gt; 72Hours&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My tables - BuyOrder, BuyOrderRow are connected by BuyOrderId in BuyOrderRow.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 10 Feb 2022 16:01:40 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Power-Query/Comparing-dates-cross-table/m-p/2331344#M69479</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-02-10T16:01:40Z</dc:date>
    </item>
    <item>
      <title>Re: Comparing dates cross table</title>
      <link>https://community.fabric.microsoft.com/t5/Power-Query/Comparing-dates-cross-table/m-p/2331354#M69481</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;can you supply some sample data? the exemple you posted is good but is not possible to get data&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 10 Feb 2022 16:07:50 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Power-Query/Comparing-dates-cross-table/m-p/2331354#M69481</guid>
      <dc:creator>serpiva64</dc:creator>
      <dc:date>2022-02-10T16:07:50Z</dc:date>
    </item>
    <item>
      <title>Re: Comparing dates cross table</title>
      <link>https://community.fabric.microsoft.com/t5/Power-Query/Comparing-dates-cross-table/m-p/2338764#M69737</link>
      <description>&lt;P&gt;Hi&amp;nbsp;Anonymous&lt;/LI-USER&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;Have created a sample table query that you can try it:&lt;/P&gt;
&lt;P&gt;BuyOrder table:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlTSUTIyMDLUNzTQN7JUMLEysbQyMVUI8FWK1YlWMkKVNbUyNLQyMoTJGuOVNcEmawGTNcUia2wElo0FAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [BuyOrderId = _t, CreatedAt = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"BuyOrderId", Int64.Type}, {"CreatedAt", type datetime}}),
    #"Merged Queries" = Table.NestedJoin(#"Changed Type", {"BuyOrderId"}, BuyOrderRow, {"BuyOrderId"}, "BuyOrderRow", JoinKind.LeftOuter),
    #"Expanded BuyOrderRow" = Table.ExpandTableColumn(#"Merged Queries", "BuyOrderRow", {"ExpectedDeliverydate"}, {"ExpectedDeliverydate"}),
    #"Added Custom" = Table.AddColumn(#"Expanded BuyOrderRow", "Confirmed", each if [ExpectedDeliverydate] &amp;lt;&amp;gt; null and [ExpectedDeliverydate] &amp;lt;&amp;gt; [CreatedAt] then 1 else 0,Int64.Type),
    #"Added Custom1" = Table.AddColumn(#"Added Custom", "HourDiff", each if Number.RoundDown(Duration.Days(Duration.From([ExpectedDeliverydate]-[CreatedAt]))) * 24+ Duration.Hours(Duration.From([ExpectedDeliverydate]-[CreatedAt])) - 48 &amp;gt; 72 then 1 else 0, Int64.Type),
    #"Replaced Errors" = Table.ReplaceErrorValues(#"Added Custom1", {{"HourDiff", 0}}),
    #"Filtered Rows" = Table.SelectRows(#"Replaced Errors", each ([Confirmed] = 1) and ([HourDiff] = 1)),
    #"Removed Columns" = Table.RemoveColumns(#"Filtered Rows",{"ExpectedDeliverydate", "Confirmed", "HourDiff"})
in
    #"Removed Columns"&lt;/LI-CODE&gt;
&lt;P&gt;BuyOrderRow table:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlTSUTIyMDLUNzTQN7JUMLEysbQyMVUI8FWK1YlWMgLKghnGcGVG+sYKhkZWBgZApOAIUWYClzXUNzLDkDZFlkaVjQUA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [BuyOrderId = _t, ExpectedDeliverydate = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"BuyOrderId", Int64.Type}, {"ExpectedDeliverydate", type datetime}})
in
    #"Changed Type"&lt;/LI-CODE&gt;
&lt;P&gt;&lt;img /&gt;&lt;img /&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;BR /&gt;Community Support Team _ Yingjie Li&lt;/P&gt;</description>
      <pubDate>Tue, 15 Feb 2022 07:07:05 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Power-Query/Comparing-dates-cross-table/m-p/2338764#M69737</guid>
      <dc:creator>v-yingjl</dc:creator>
      <dc:date>2022-02-15T07:07:05Z</dc:date>
    </item>
  </channel>
</rss>

