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
webportal
Impactful Individual
Impactful Individual

Filter a column in Power Query so that it contains only the last date of each year

Can anyone please advise on how to filter this column in Power Query so that it contains only the last date of each year?

webportal_0-1620241744054.png

 

So, this should contain only 3 rows:

  • 31/12/2019
  • 31/12/2020
  • 31/03/2021

Thank you!

1 ACCEPTED SOLUTION
v-angzheng-msft
Community Support
Community Support

 Hi, @webportal 

 

Create a secondary table

  1. Copy a table named Table 2
  2. Insert the year column in table 2
  3. Group by year column to get the last date
  4. merge table 1 and 2 to expand the last date column
  5. Filter to filter null values

 

It must be noted that the data format of the date column cannot be text.

 

In order to test the correct logic, I changed the maximum date from December 31 to December 30

Sample:

v-angzheng-msft_0-1620609927718.jpeg

Result:

v-angzheng-msft_1-1620609927720.jpeg

 

v-angzheng-msft_2-1620609927723.jpeg

 

Please refer to the attachment below for details

 

 

Is this the result you want? Hope this is useful to you

Please feel free to let me know If you have further questions

 

Best Regards,
Community Support Team _ Zeon Zheng
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

3 REPLIES 3
v-angzheng-msft
Community Support
Community Support

 Hi, @webportal 

 

Create a secondary table

  1. Copy a table named Table 2
  2. Insert the year column in table 2
  3. Group by year column to get the last date
  4. merge table 1 and 2 to expand the last date column
  5. Filter to filter null values

 

It must be noted that the data format of the date column cannot be text.

 

In order to test the correct logic, I changed the maximum date from December 31 to December 30

Sample:

v-angzheng-msft_0-1620609927718.jpeg

Result:

v-angzheng-msft_1-1620609927720.jpeg

 

v-angzheng-msft_2-1620609927723.jpeg

 

Please refer to the attachment below for details

 

 

Is this the result you want? Hope this is useful to you

Please feel free to let me know If you have further questions

 

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

@v-angzheng-msft I think @webportal  is looking for the last date in the year, not the last date used in the year

// if this is a solution please mark as such. Kudos always appreciated.
samdthompson
Memorable Member
Memorable Member

Hello, you could try the last day of year funtion in power query, on a duplicate of your table then remove duplicates on the column, that would leave you with just the last days of the year:

 

2021-05-06_7-15-42.jpg

// if this is a solution please mark as such. Kudos always appreciated.

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.