<?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 Dynamic File Import in Report Server</title>
    <link>https://community.fabric.microsoft.com/t5/Report-Server/Dynamic-File-Import/m-p/4577296#M39810</link>
    <description>&lt;P&gt;I have a model that is built off of four Excel files that are stored in a network folder.&amp;nbsp; The network folder contains several files that aren't associated with my model, but I need the most recent version of the four files.&amp;nbsp; My dilemma is that the files have datestamps, and files from previous days need to be kept for auditing purposes.&amp;nbsp; My steps are as follows:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1. = Folder.Files("FolderPath")&lt;/P&gt;&lt;P&gt;2.&amp;nbsp;= Table.SelectRows (Source, each&lt;BR /&gt;Text.Contains ([Name], "Text in Filename"))&lt;/P&gt;&lt;P&gt;3.&amp;nbsp;= Table.Sort(Filtered,{{"Date modified", Order.Descending}})&lt;/P&gt;&lt;P&gt;4.&amp;nbsp;= Table.FirstN(#"Sorted Rows",4)&lt;/P&gt;&lt;P&gt;5.&amp;nbsp;= Table.SelectRows(#"Kept First Rows", each Text.Contains([Name], "Text in Filename"))&lt;/P&gt;&lt;P&gt;6.&amp;nbsp;= #"Filtered Rows"{[#"Folder Path"="Filename with Specific Date"]}[Content]&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How should I modify my steps so they find the most recent file that contains "X" in the name?&lt;/P&gt;</description>
    <pubDate>Tue, 25 Feb 2025 16:50:54 GMT</pubDate>
    <dc:creator>JeffP25</dc:creator>
    <dc:date>2025-02-25T16:50:54Z</dc:date>
    <item>
      <title>Dynamic File Import</title>
      <link>https://community.fabric.microsoft.com/t5/Report-Server/Dynamic-File-Import/m-p/4577296#M39810</link>
      <description>&lt;P&gt;I have a model that is built off of four Excel files that are stored in a network folder.&amp;nbsp; The network folder contains several files that aren't associated with my model, but I need the most recent version of the four files.&amp;nbsp; My dilemma is that the files have datestamps, and files from previous days need to be kept for auditing purposes.&amp;nbsp; My steps are as follows:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1. = Folder.Files("FolderPath")&lt;/P&gt;&lt;P&gt;2.&amp;nbsp;= Table.SelectRows (Source, each&lt;BR /&gt;Text.Contains ([Name], "Text in Filename"))&lt;/P&gt;&lt;P&gt;3.&amp;nbsp;= Table.Sort(Filtered,{{"Date modified", Order.Descending}})&lt;/P&gt;&lt;P&gt;4.&amp;nbsp;= Table.FirstN(#"Sorted Rows",4)&lt;/P&gt;&lt;P&gt;5.&amp;nbsp;= Table.SelectRows(#"Kept First Rows", each Text.Contains([Name], "Text in Filename"))&lt;/P&gt;&lt;P&gt;6.&amp;nbsp;= #"Filtered Rows"{[#"Folder Path"="Filename with Specific Date"]}[Content]&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How should I modify my steps so they find the most recent file that contains "X" in the name?&lt;/P&gt;</description>
      <pubDate>Tue, 25 Feb 2025 16:50:54 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Report-Server/Dynamic-File-Import/m-p/4577296#M39810</guid>
      <dc:creator>JeffP25</dc:creator>
      <dc:date>2025-02-25T16:50:54Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic File Import</title>
      <link>https://community.fabric.microsoft.com/t5/Report-Server/Dynamic-File-Import/m-p/4585699#M39819</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="1227739" data-lia-user-login="JeffP25" class="lia-mention lia-mention-user"&gt;JeffP25&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class="lia-align-left"&gt;Maybe you can try the following expression:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;let
    // Step 1: Get all the files in the folder
    Source = Folder.Files("FolderPath"),
  
    // Step 2: Filter for file names that contain "X".
    FilteredByText = Table.SelectRows(Source, each Text.Contains([Name], "X")),
  
    // Step 3: Extract the identifier in the file name (assuming the format is "Identifier_Date.xlsx")
    ExtractIdentifier = Table.AddColumn(FilteredByText, "Identifier", each Text.BeforeDelimiter([Name], "_")),
  
    // Step 4: Group by identifier and take the latest file for each group
    GroupAndSelectLatest = Table.Group(ExtractIdentifier, {"Identifier"}, {
        "LatestFile", each Table.Sort(_, {{"Date modified", Order.Descending}}){0}
    }),
  
    // Step 5: Expand and merge the file contents
    ExpandContent = Table.ExpandRecordColumn(GroupAndSelectLatest, "LatestFile", {"Content"}, {"Content"}),
    ImportExcelData = Table.TransformRows(ExpandContent, (row) =&amp;gt; Excel.Workbook(row[Content]){0}[Data])
in
    ImportExcelData&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A title="https://community.powerbi.com/t5/community-blog/how-to-get-your-question-answered-quickly/ba-p/38490" href="https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fcommunity.powerbi.com%2Ft5%2FCommunity-Blog%2FHow-to-Get-Your-Question-Answered-Quickly%2Fba-p%2F38490&amp;amp;data=05%7C02%7Cv-yohua%40microsoft.com%7Ce1106bfabecb4734a5cc08dc2305bc51%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C638423754744679080%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C0%7C%7C%7C&amp;amp;sdata=24%2BceC5sFd3n3%2FhFDYILWFcNjCwVClBD%2BPBsSLVfJGk%3D&amp;amp;reserved=0" target="_blank" rel="noreferrer noopener nofollow"&gt;How to Get Your Question Answered Quickly&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;Best Regards&lt;/P&gt;
&lt;P&gt;Yongkang Hua&lt;/P&gt;
&lt;P&gt;If this post&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;helps&lt;/STRONG&gt;, then please consider&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;Accept it as the solution&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;to help the other members find it more quickly.&lt;/P&gt;</description>
      <pubDate>Wed, 26 Feb 2025 07:10:37 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Report-Server/Dynamic-File-Import/m-p/4585699#M39819</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2025-02-26T07:10:37Z</dc:date>
    </item>
  </channel>
</rss>

