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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
hymieho
Resolver I
Resolver I

Combine multiple CSV files, then add IsLatest column based on date in filename in Power Query / M

I am importing a series of CSV file and they all have a date in the file name.  Ex:

 

2017-09-26.CSV

2017-10-23.CSV

etc.

 

I am able to combine them and create a date column based on the filename. Now I would like to add a column called [IsLatest, determine which is the most recent date, and have Yes or No in the column accordingly. I can do this in DAX with a custom column, but I wanted to stretch my M skills but I just can't figure it out. Any Power Query / M gurus who can point me in the right direction?

1 ACCEPTED SOLUTION
v-jiascu-msft
Employee
Employee

Hi @hymieho,

 

You can try a custom column like this:

List.Max(#"Changed Type"[Column1])

Combine_multiple_CSV_files

 

Best Regards,

Dale

Community Support Team _ Dale
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
v-jiascu-msft
Employee
Employee

Hi @hymieho,

 

You can try a custom column like this:

List.Max(#"Changed Type"[Column1])

Combine_multiple_CSV_files

 

Best Regards,

Dale

Community Support Team _ Dale
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Works like a charm--thanks for the tip!

 

1. Add a (temporary) custom column as you mentioned with the List.Max(date)

2. Add a 2nd custom column that checks to see if [Date] = [Latest Date in group]

3. Remove the temp column

 

#"Added Conditional Column" = Table.AddColumn(#"Added Custom", "IsLatest", each if [Add Column with latest date] = [Date] then "Yes" else "No"),
#"Renamed Columns2" = Table.RenameColumns(#"Added Conditional Column",{{"Add Column with latest date", "Latest Date in group"}}),
#"Removed Columns1" = Table.RemoveColumns(#"Renamed Columns2",{"Latest Date in group"})

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors