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:
![](http://sumproduct-4634.kxcdn.com/img/containers/main/blog-pictures/2019/power-query/130/image1.png/e774d10cbbb9450fc45efbe51abdf434.jpg)
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.
![](http://sumproduct-4634.kxcdn.com/img/containers/main/blog-pictures/2019/power-query/130/image2.png/f32e5a15e2cf9c3e4d2d058458ce054d.jpg)
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’:
![](http://sumproduct-4634.kxcdn.com/img/containers/main/blog-pictures/2019/power-query/130/image3.png/f1140ff857fc3b6f5f97a6a24f4a6fc7.jpg)
I choose to ‘Transform Data’, so that I can select which files I want to combine.
![](http://sumproduct-4634.kxcdn.com/img/containers/main/blog-pictures/2019/power-query/130/image4.png/72aa864d2854c6fefb1083fba0ab5792.jpg)
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’.
![](http://sumproduct-4634.kxcdn.com/img/containers/main/blog-pictures/2019/power-query/130/image5.png/36776d1da4d05b45bb5a5d09375f407c.jpg)
As shown above, using the ‘Column From Examples’ option, I create a new column with the date and time.
![](http://sumproduct-4634.kxcdn.com/img/containers/main/blog-pictures/2019/power-query/130/image6.png/23912d3b1671861e02bebcd5183f1607.jpg)
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.
![](http://sumproduct-4634.kxcdn.com/img/containers/main/blog-pictures/2019/power-query/130/image7.png/6f49c288a0d88a66b427eaf4ece923d6.jpg)
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.
![](http://sumproduct-4634.kxcdn.com/img/containers/main/blog-pictures/2019/power-query/130/image8.png/b9ee28d90e6b5bc92ea4aeafdad51628.jpg)
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.
![](http://sumproduct-4634.kxcdn.com/img/containers/main/blog-pictures/2019/power-query/130/image9.png/0485ccbc83bdeec1d741bad442a1ea5f.jpg)
The Calendar table appears as a column, and I can expand it to choose what columns I want in my query.
![](http://sumproduct-4634.kxcdn.com/img/containers/main/blog-pictures/2019/power-query/130/image10.png/daf8c4f0259ce428269c0d3d4badd32b.jpg)
I am only interested in ‘Days from Today’ so I choose that option (without the prefix!).
![](http://sumproduct-4634.kxcdn.com/img/containers/main/blog-pictures/2019/power-query/130/image11.png/22c6daeb82d7d69ac88f878227e04b28.jpg)
I can see that the only files I need to upload are the ones with zero (0) in Days from Today.
![](http://sumproduct-4634.kxcdn.com/img/containers/main/blog-pictures/2019/power-query/130/image12.png/a1537847463e660a31158c8032525438.jpg)
This gives me the files which I want to extract and combine together.
![](http://sumproduct-4634.kxcdn.com/img/containers/main/blog-pictures/2019/power-query/130/image13.png/917da985be13220165c8d2823e95344f.jpg)
I can delete everything apart from the Content column and expand my data.
![](http://sumproduct-4634.kxcdn.com/img/containers/main/blog-pictures/2019/power-query/130/image14.png/8c3be7af9f73d031acae69ed85a2e148.jpg)
The data looks fine so I continue.
![](http://sumproduct-4634.kxcdn.com/img/containers/main/blog-pictures/2019/power-query/130/image15.png/e63c0a4c21afc9afb438aacc09a59317.jpg)
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!