Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
EmaVasileva
Helper V
Helper V

Year formula - dynamically changing

Hey all,

I'm kindly ask for a little help regarding a calculated column or a metric. I need to create a field which to show me (to filter) data only for the last available completed year. For example if I have a bar chart and today is April 13th, 2020, I need to have the data filtered for the full 2019. If Today is January 1st, 2021, I need the data to be filtered automatically for the full 2020, and every year this field to be updated dynamically.

Is it possible?

Thank you.

2 ACCEPTED SOLUTIONS
Greg_Deckler
Super User
Super User

Perhaps:

 

Measure = 
  VAR __Year = YEAR(TODAY())
RETURN
  SUMX(FILTER('Table',YEAR([Date]) = __Year - 1),[Column])


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

amitchandak
Super User
Super User

In case you calendar end in the same year or date is selected

Last YTD complete Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD(ENDOFYEAR(dateadd('Date'[Date],-1,Year)),"12/31"))

 

Measure =

var _max = year(Today())-1

Return

CALCULATE(SUM(Sales[Sales Amount]), Year(Sales[Sales date]) =_max)

 

or

Measure =

var _max = year(Today())-1

Return

CALCULATE(SUM(Sales[Sales Amount]), Year(Date[Date]) =_max)

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

View solution in original post

5 REPLIES 5
amitchandak
Super User
Super User

In case you calendar end in the same year or date is selected

Last YTD complete Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD(ENDOFYEAR(dateadd('Date'[Date],-1,Year)),"12/31"))

 

Measure =

var _max = year(Today())-1

Return

CALCULATE(SUM(Sales[Sales Amount]), Year(Sales[Sales date]) =_max)

 

or

Measure =

var _max = year(Today())-1

Return

CALCULATE(SUM(Sales[Sales Amount]), Year(Date[Date]) =_max)

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

Hi @amitchandak 

Thank you for the formula. It helps me with another task. 

@EmaVasileva , I was trying to solve the invisible task. 😀 🤔

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here
Greg_Deckler
Super User
Super User

Perhaps:

 

Measure = 
  VAR __Year = YEAR(TODAY())
RETURN
  SUMX(FILTER('Table',YEAR([Date]) = __Year - 1),[Column])


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

Hi @Greg_Deckler 

Thank you for the response. It helps and the task has been done.

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.