Please note javascript is required for full website functionality.

Blog

Power Query: Check Today’s Calendar

29 May 2019

Welcome to our Power Query blog. Today, I am going to look at an example which uses a Calendar table to filter on today’s date.

Last week, I looked at how to add a column to the Calendar table which held the relationship between the current date and the calendar date:

I am going to use this calendar in an example which selects data based on a date. I have some expense data, which I only want to upload if the file name matches today’s date.

This is similar to the issue I encountered in Power Query: Files for Today, but this time I am going to use my Calendar table.

I begin in the same way as previously: I choose to extract my data ‘From Folder’:

I choose to ‘Transform Data’, so that I can select which files I want to combine.

Before I can link this data to the Calendar table, I need to extract the dates from the file names. I am only interested in the first two columns: Content and Name, so I select these two columns whilst holding down the CTRL key and right click to ‘Remove Other Columns’.

As shown above, using the ‘Column From Examples’ option, I create a new column with the date and time.

I rename my new column. I need to change the data type of File Date so that I can link to my Calendar table. I can do this on the ‘Transform’ tab where the current data type is set to text.

I choose the ‘Merge Queries’ option on the ‘Home’ tab. I choose to simply merge queries as I don’t need to create a new one.

I choose to merge with the ‘Calendar’ query. I need to specify how to link; I will link Date on the Calendar query to File Date on my current query. I can take the default left join as I only want those Calendar rows that match dates in my query.

The Calendar table appears as a column, and I can expand it to choose what columns I want in my query.

I am only interested in ‘Days from Today’ so I choose that option (without the prefix!).

I can see that the only files I need to upload are the ones with zero (0) in Days from Today.

This gives me the files which I want to extract and combine together.

I can delete everything apart from the Content column and expand my data.

The data looks fine so I continue.

The correct files have been extracted, and I can transform my data into the required format.

Come back next time for more ways to use Power Query!

Newsletter