<?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: Filter table based on date in Power Query</title>
    <link>https://community.fabric.microsoft.com/t5/Power-Query/Filter-table-based-on-date/m-p/2629383#M80452</link>
    <description>&lt;P&gt;Anonymous&lt;/LI-USER&gt;&amp;nbsp;Adding the custom column is a great way to visualize which rows get filtered but it's also possible to do the filtering in one step with exactly the same logic rather than the three steps of adding a column, filtering that column, and then deleting that column.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The /*[abbreviated]*/ query would look like this instead:&lt;/P&gt;
&lt;LI-CODE lang="php"&gt;let
    Source = Table.FromRows(/*[...]*/),
    #"Changed Type" = Table.TransformColumnTypes(Source, {/*[...]*/}),
    #"Filtered Rows" = Table.SelectRows(#"Changed Type",
        each ([To submit as from] &amp;lt;= Date.StartOfWeek(Date.From(DateTime.FixedLocalNow()),1) or
              [To submit as from] = null))
in
    #"Filtered Rows"&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sun, 10 Jul 2022 22:43:39 GMT</pubDate>
    <dc:creator>AlexisOlson</dc:creator>
    <dc:date>2022-07-10T22:43:39Z</dc:date>
    <item>
      <title>Filter table based on date</title>
      <link>https://community.fabric.microsoft.com/t5/Power-Query/Filter-table-based-on-date/m-p/2626254#M80312</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I have the following table loaded in Power BI (Power Query). The table is called the Reference table.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Student Name&lt;/TD&gt;&lt;TD&gt;To submit as from&lt;/TD&gt;&lt;TD&gt;Submission optional (Yes/No)&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Lizui&lt;/TD&gt;&lt;TD&gt;02 July 2022&lt;/TD&gt;&lt;TD&gt;No&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Laufenburg&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;Yes&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Tegalpapak&lt;/TD&gt;&lt;TD&gt;29 August 2022&lt;/TD&gt;&lt;TD&gt;No&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Ar Rabiyah&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Bellegarde&lt;/TD&gt;&lt;TD&gt;02 July 2022&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Gangarampur&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;No&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Luntas&lt;/TD&gt;&lt;TD&gt;05 May 2022&lt;/TD&gt;&lt;TD&gt;Yes&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Frei Paulo&lt;/TD&gt;&lt;TD&gt;10 August 2022&lt;/TD&gt;&lt;TD&gt;Yes&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Seedorf&lt;/TD&gt;&lt;TD&gt;03 July 2022&lt;/TD&gt;&lt;TD&gt;No&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Cosamaloapan de Carpio&lt;/TD&gt;&lt;TD&gt;10 September 2022&lt;/TD&gt;&lt;TD&gt;No&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;The goal is to &lt;/SPAN&gt;&lt;SPAN&gt;generate a new table called Results with a single column showing the list of Student names based on the following condition:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;1. If the&amp;nbsp;"To submit as from" date is &lt;U&gt;before&lt;/U&gt; the current week (based on the ISO week date calendar, so, the week always starts on Monday and ends on Sunday). The current week started on Monday, 4 July 2022.&lt;/P&gt;&lt;P&gt;2. If the "To submit as from" date is blank/null, then the date should be assumed to be before the current week.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The Results table should be as below:&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Student Name&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Lizui&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Laufenburg&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Ar Rabiyah&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Bellegarde&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Gangarampur&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Luntas&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Seedorf&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Is it possible to do this entirely in Power Query? Any help is much appreciated!&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 07 Jul 2022 21:26:35 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Power-Query/Filter-table-based-on-date/m-p/2626254#M80312</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-07-07T21:26:35Z</dc:date>
    </item>
    <item>
      <title>Re: Filter table based on date</title>
      <link>https://community.fabric.microsoft.com/t5/Power-Query/Filter-table-based-on-date/m-p/2626266#M80314</link>
      <description>&lt;P&gt;Yes, it's possible with PQ, there are a lot of date-related functions. Your high- level logic would be&amp;nbsp;to 1) start with the #2 nulls, then 2) deal with #1 using a conditional column. Filter on the outcome of that conditional column then drop all columns but Student Name.&lt;/P&gt;</description>
      <pubDate>Thu, 07 Jul 2022 21:39:10 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Power-Query/Filter-table-based-on-date/m-p/2626266#M80314</guid>
      <dc:creator>otravers</dc:creator>
      <dc:date>2022-07-07T21:39:10Z</dc:date>
    </item>
    <item>
      <title>Re: Filter table based on date</title>
      <link>https://community.fabric.microsoft.com/t5/Power-Query/Filter-table-based-on-date/m-p/2626310#M80316</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="21459" data-lia-user-login="otravers" class="lia-mention lia-mention-user"&gt;otravers&lt;/a&gt;&amp;nbsp;Thanks for your reply! But i am a beginner at Power Query. I am not sure about the code. I found this example and it is quite confusing!&amp;nbsp;&lt;A href="https://community.powerbi.com/t5/Desktop/Power-Query-choose-a-step-to-create-based-on-a-condition/m-p/385799" target="_blank"&gt;https://community.powerbi.com/t5/Desktop/Power-Query-choose-a-step-to-create-based-on-a-condition/m-p/385799&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 07 Jul 2022 22:42:09 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Power-Query/Filter-table-based-on-date/m-p/2626310#M80316</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-07-07T22:42:09Z</dc:date>
    </item>
    <item>
      <title>Re: Filter table based on date</title>
      <link>https://community.fabric.microsoft.com/t5/Power-Query/Filter-table-based-on-date/m-p/2626328#M80320</link>
      <description>&lt;P&gt;You can do a lot with Power Query just with the UI without writing your own M code. Start with this:&lt;/P&gt;&lt;P&gt;&lt;A href="https://docs.microsoft.com/en-us/power-query/add-conditional-column" target="_self"&gt;https://docs.microsoft.com/en-us/power-query/add-conditional-column&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 07 Jul 2022 23:59:55 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Power-Query/Filter-table-based-on-date/m-p/2626328#M80320</guid>
      <dc:creator>otravers</dc:creator>
      <dc:date>2022-07-07T23:59:55Z</dc:date>
    </item>
    <item>
      <title>Re: Filter table based on date</title>
      <link>https://community.fabric.microsoft.com/t5/Power-Query/Filter-table-based-on-date/m-p/2626780#M80333</link>
      <description>&lt;P&gt;See the working here - Open a blank query - Home - Advanced Editor - Remove everything from there and paste the below code to test (later on when you use the query on your dataset, you will have to change the source appropriately. If you have columns other than these, then delete Changed type step and do a Changed type for complete table from UI again)&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("ZY9BC4JAEIX/iuzZhTI6dDShICoiu4R4GHG0pXV3WZuD/fomTUSCOey8N9/smywTR/UmJUIRyQNpGUX8PFuRh+wAVWgK8jVrXHdse/2GNWgHDp5fbCNjqmdc7IMrFKqDx8D14ha1Zs6XOP+rN/dg2ILGkR+QMQGZF7Tcr+UJugEYU+w8quACpC2Ly8WUYhxIEUvrK1ZWf6cltoUGtOUjTFBikIB36rcoRTfN5h8=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Student Name" = _t, #"To submit as from" = _t, #"Submission optional (Yes/No)" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Student Name", type text}, {"To submit as from", type date}, {"Submission optional (Yes/No)", type text}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each [To submit as from]&amp;lt;=Date.StartOfWeek(Date.From(DateTime.FixedLocalNow()),1) or [To submit as from]=null),
    #"Filtered Rows" = Table.SelectRows(#"Added Custom", each ([Custom] = true)),
    #"Removed Columns" = Table.RemoveColumns(#"Filtered Rows",{"To submit as from", "Submission optional (Yes/No)", "Custom"})
in
    #"Removed Columns"&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 08 Jul 2022 05:19:20 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Power-Query/Filter-table-based-on-date/m-p/2626780#M80333</guid>
      <dc:creator>Vijay_A_Verma</dc:creator>
      <dc:date>2022-07-08T05:19:20Z</dc:date>
    </item>
    <item>
      <title>Re: Filter table based on date</title>
      <link>https://community.fabric.microsoft.com/t5/Power-Query/Filter-table-based-on-date/m-p/2629383#M80452</link>
      <description>&lt;P&gt;Anonymous&lt;/a&gt;&amp;nbsp;Adding the custom column is a great way to visualize which rows get filtered but it's also possible to do the filtering in one step with exactly the same logic rather than the three steps of adding a column, filtering that column, and then deleting that column.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The /*[abbreviated]*/ query would look like this instead:&lt;/P&gt;
&lt;LI-CODE lang="php"&gt;let
    Source = Table.FromRows(/*[...]*/),
    #"Changed Type" = Table.TransformColumnTypes(Source, {/*[...]*/}),
    #"Filtered Rows" = Table.SelectRows(#"Changed Type",
        each ([To submit as from] &amp;lt;= Date.StartOfWeek(Date.From(DateTime.FixedLocalNow()),1) or
              [To submit as from] = null))
in
    #"Filtered Rows"&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 10 Jul 2022 22:43:39 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Power-Query/Filter-table-based-on-date/m-p/2629383#M80452</guid>
      <dc:creator>AlexisOlson</dc:creator>
      <dc:date>2022-07-10T22:43:39Z</dc:date>
    </item>
  </channel>
</rss>

