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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
MonirSikder
Regular Visitor

Date table column with rolling years for each previous 365 days. How can i do that on Power BI?

Hi all,

How can I create a column with rolling years for each previous 365 days. How can i do that on Power BI? last 365 as -Y1, followed by -Y2, -Y3 and it counts backwards.

1 ACCEPTED SOLUTION
m_dekorte
Super User
Super User

Hi @MonirSikder ,

 

You could give something like this a go.

Just copy the script below into a new blank query.

 

let
  Source = Table.FromColumns(
    {List.Dates(#date(2021, 1, 1), 3 * 365, Duration.From(1))}, 
    type table [Date = date]
  ), 
  AddRollingYear = Table.AddColumn( Source, "Rolling Year", each 
    [ n = Number.Round( -Number.From( Date.From( DateTime.FixedLocalNow()) - [Date] )/ 365, 0), 
      r = if n < 0 then Text.From(n) & "Y" else null
    ][r], type text
  )
in
  AddRollingYear

 

It's relative to today, amend to your needs.

 

m_dekorte_0-1680900172105.png

 

 

View solution in original post

1 REPLY 1
m_dekorte
Super User
Super User

Hi @MonirSikder ,

 

You could give something like this a go.

Just copy the script below into a new blank query.

 

let
  Source = Table.FromColumns(
    {List.Dates(#date(2021, 1, 1), 3 * 365, Duration.From(1))}, 
    type table [Date = date]
  ), 
  AddRollingYear = Table.AddColumn( Source, "Rolling Year", each 
    [ n = Number.Round( -Number.From( Date.From( DateTime.FixedLocalNow()) - [Date] )/ 365, 0), 
      r = if n < 0 then Text.From(n) & "Y" else null
    ][r], type text
  )
in
  AddRollingYear

 

It's relative to today, amend to your needs.

 

m_dekorte_0-1680900172105.png

 

 

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!

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors