Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Saxon10
Post Prodigy
Post Prodigy

DAX measure Pick up the latest file.

Hi,

 

I have a two tables are one is data and another one is report. Data file contain “item” and “sales code” and report file contain “item”.

In order to pull the sales code against the item in report file I am using following DAX measure lookvalue. (from data file to report file).

 The folder name is "Sale Data" under the "Sales Data" folder I am stored the daily sales details in Excel.

The sales file name is "TRP_KPY" always same but date and time keep changing on a daily basis “TRP_KPY_07-11-2020_08:00".

 The sales file data structure are same (headers and headers orders always same manner "Item, sales code") 

 I am trying to get the report against the latest file but currently I am changing the data source manually.

Example:

Folder Name is "Sale Data".

File name:

TRP_KPY_07-11-2020_08:00"

TRP_KPY_06-11-2020_08:30"

TRP_KPY_05-11-2020_08:00"

TRP_KPY_04-11-2020_07:00"

TRP_KPY_03-11-2020_01:00"

 

How can I automated the report? (DAX measure pull the sales code against the item corresponding to the latest file)

Could you please advise.  

1 ACCEPTED SOLUTION
mahoneypat
Microsoft Employee
Microsoft Employee

Here is how to do this.  In your existing query (assuming you use the Folder connector to get a list of files), you probably generated a step like this when you selected the file to use (check the View Formula Bar if you don't see it).

= #"Filtered Rows"{[#"Folder Path"="C:\Folder\Subfolder",Name="examplefile.csv"]}[Content]

 

To get the latest file instead, at the previous step sort the table descending by modified date, and then revise the above to this

= #"Filtered Rows"{0}[Content]

 

This references the first row and since you sorted descending, it will give you the contents of the latest file.

 

Regards,

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


View solution in original post

4 REPLIES 4
mahoneypat
Microsoft Employee
Microsoft Employee

Here is how to do this.  In your existing query (assuming you use the Folder connector to get a list of files), you probably generated a step like this when you selected the file to use (check the View Formula Bar if you don't see it).

= #"Filtered Rows"{[#"Folder Path"="C:\Folder\Subfolder",Name="examplefile.csv"]}[Content]

 

To get the latest file instead, at the previous step sort the table descending by modified date, and then revise the above to this

= #"Filtered Rows"{0}[Content]

 

This references the first row and since you sorted descending, it will give you the contents of the latest file.

 

Regards,

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


Hi. Thanks for your quick response. I am new to Power Bi. If possible could you please provide the snap shot step by step in order to understand your solution so I can try my end and I will update the feedback to you. 

This video walks through it (almost the same approach).

https://www.youtube.com/watch?v=m9XCmS0UzHc

 

Regards,

Pat

 





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


You are star. Thank you so much for your guideline. It's very uselfull. 

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.