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
huihui
Regular Visitor

Get latest date of each year

Hi all, i would like to retrieve the data of the latest date of every year.

Below is an example of what i want to achieve:

 

MyTable:

 

image.png

 

 

 

 

 

 

 

 

 

 

After:

image.png

 

 

 

 

 

 

 

 

Hopefully someone can guide me through. Thank you!

1 ACCEPTED SOLUTION
v-ljerr-msft
Employee
Employee

Hi @huihui,

 

Based on my test, you should be able to follow steps below to get your expected result.

 

1. Use the formula below to add a calculate column in your table to indicate if the current date if the latest date of its year.

IsLatestDateofYear = 
VAR currentYear =
    YEAR ( MyTable[date] )
VAR latestDateofYear =
    CALCULATE (
        MAX ( MyTable[date] ),
        FILTER ( ALL ( MyTable ), YEAR ( MyTable[date] ) = currentYear )
    )
RETURN
    IF ( MyTable[date] = latestDateofYear, 1, 0 )

c1.PNG

 

2. Then you should be able to use this calculate column as a Slicer on the report to retrieve the data of the latest date of every year. Smiley Happy

 

r1.PNG

Regards

View solution in original post

3 REPLIES 3
v-ljerr-msft
Employee
Employee

Hi @huihui,

 

Based on my test, you should be able to follow steps below to get your expected result.

 

1. Use the formula below to add a calculate column in your table to indicate if the current date if the latest date of its year.

IsLatestDateofYear = 
VAR currentYear =
    YEAR ( MyTable[date] )
VAR latestDateofYear =
    CALCULATE (
        MAX ( MyTable[date] ),
        FILTER ( ALL ( MyTable ), YEAR ( MyTable[date] ) = currentYear )
    )
RETURN
    IF ( MyTable[date] = latestDateofYear, 1, 0 )

c1.PNG

 

2. Then you should be able to use this calculate column as a Slicer on the report to retrieve the data of the latest date of every year. Smiley Happy

 

r1.PNG

Regards

Omg thanks it works! But i am not sure why when i use that column to as a filter, i show no results though.

Hi @huihui,

 

If you don't want to show that column as a Slicer on the report, you can also use it to apply a visual/page/report level filter to get the same result. For more details about how to apply a visual/page/report level filter, you can refer to this article. Smiley Happy

 

Regards

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.