cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Nanaki
Helper II
Helper II

Dynamic Date Title

Hi,

I want to insert years as a title into a card. Like shown in the picture. 

The last card "2022" is always this year. I did this with the formula "=NOW()"

Each year the title should change to the next year.
But I dont know how to set the title for the previous year and the title for two years ago. 
Is there a formula, with which i can just say: "Give me this year minus 1 year ? 

Nanaki_0-1643023301822.png

 

Thanks in advance. 
Best regards. 

 

1 ACCEPTED SOLUTION

If you want a date you a year ago you can create the following measure:

Date a Year Ago = DATE(YEAR(TODAY())-1,MONTH(TODAY()), DAY(TODAY()))

View solution in original post

10 REPLIES 10
Noorani
Helper II
Helper II

Hi @Nanaki,

 

Try using the PREVIOUSYEAR() function along with the YEAR().

Here's the documentation: PREVIOUSYEAR function (DAX) - DAX | Microsoft Docs

 

I hope it helps

amitchandak
Super User
Super User

@Nanaki ,measure or column as per need

 

This Year = year(Today())

 

Next Year = year(Today()) +1

 

Last Year = year(Today()) -1



New Power BI Features
Datamarts: https://youtu.be/8tskWsJTEpg
Field Parameters : https://youtu.be/lqF3Wa1FllE?t=70
Did I answer your question? Mark my post as a solution! Appreciate your Kudos!! !!
Dashboard of My Blogs !! Connect on Linkedin !! Proud to be a Super User!
Want To Learn Power BI
Learn Power BI Beginners !! Advance Power BI Concepts !! Power BI For Tableau User !! Learn Power BI in Hindi !!
!! Subscribe to my youtube Channel !!

Thank you for your fast reply.
But I still get strangely 1905 for the last year. 

@Nanaki  Can you share screen shot of your date column and check which data type it is. 

Don't forget to give thumbs up and accept this as a solution if it helped you!!!

Please take a quick glance at newly created dashboards : Restaurant Management Dashboard , HR Analytics Report , Hotel Management Report, Sales Analysis Report , and Fortune 500 Companies Analysis

In the first picture you can see the formula "today" with the today date.

And in the 2. picture with "year(today)" i get the year 1905.

Nanaki_0-1643029707611.pngNanaki_1-1643029745115.png

 

Hi @Nanaki,

 

13-7-1905 is the date value of number 2021. You can see this e.g. in Excel by changing the format into Short Date of a cell containing 2021.

 

I can reproduce the behaviour you experience when I create a new column instead of a measure

PierrreVelraeds_0-1643031550921.png

PierrreVelraeds_1-1643031570030.png

Defintions:

  • Column Last Year = year(Today()) -1
  • Last Year = year(Today()) -1

Solution is then to create a measure with that definition.

But with that solution I wont get the year 2021 in a date format right? Only in a number format ? 

If you want a date you a year ago you can create the following measure:

Date a Year Ago = DATE(YEAR(TODAY())-1,MONTH(TODAY()), DAY(TODAY()))

Awesome, this worked. Thank you very much to all of you!

I dont have a column, I just have this formula. I created it manually as a measure and wanted to insert it into one card.

Helpful resources

Announcements
June 2022 update 768X460.jpg

Check it out!

Click here to read more about the June 2022 updates!

Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Power BI Dev Camp Session 23 768x460.jpg

Check it Out!

Mark your calendars and join us on Thursday, June 30 at 11a PDT for a great session with Ted Pattison!

June 20 episode 7 with aka link 768x460.jpg

The Power BI Community Show

Join us on June 20 at 11 am PDT when Kim Manis shares the latest on Azure Synapse analytics, the Microsoft Intelligent Data Platform, and notable Power BI Updates from Microsoft Build 2022.

Top Solution Authors