cancel
Showing results for
Did you mean:
Highlighted
Regular Visitor

## Create a List of Years

I need a list of the past 5 years in a new table, so the column would have (2013 ... 2016, 2017). List.Dates seems like the perfect function for this except the duration functions that it requires only have intervals of days/hrs/minutes as far as I can tell. Any way of doing this by way of formula instead of manually?

Thanks

Pierre

1 ACCEPTED SOLUTION

Accepted Solutions
Super Contributor

## Re: Create a List of Years

Hi @pierre415,

Based on my test, you should also be able to use the formula(DAX) below to create a new calculate table to make an automated list of past 5 years that updates itself over the years.

```Year =
DISTINCT (
SELECTCOLUMNS (
CALENDAR ( DATE ( YEAR ( TODAY () ) - 4, 1, 1 ), TODAY () ),
"Year", YEAR ( [Date] )
)
)
```

Regards

5 REPLIES 5
Established Member

## Re: Create a List of Years

@pierre415 - You could use the enter data function in the deskptop ribbon.

Giles

Regular Visitor

## Re: Create a List of Years

Thanks, I'm looking to make an automated list that updates itself over the years though

Member

## Re: Create a List of Years

For something this straightforward, you can manually create a table. Simply click on "Enter Data" on the top ribbon of Power Bi and it will allow you to manually enter a small dataset like this.

If you want/need something fancier without getting into utilizing complex M functions (M is great but sometimes the heavy lifting is better off being done by the big boys such as Chris Webb instead of mere mortals like us), you can use the "New Table" functionality that is in Power BI. So for example, if the data you need for a look up table is contained within your fact table, you could create a dynamic table by using some of the "table" functions of DAX. So in this case, if all 5 years you need are con[tained in your fact table, you can simply do the following:

1. Select "modeling" tab

2. Select "New Table"

3. In formula bar, create new table with following syntax:

Year Table = ALL('FACT_TABLE_NAME'[YEAR])

That's it. If you want more details on the create table functionality, there's a great blog post by @MattAllington (whom you will see frequently posting on this forum and all around the web on the Microsoft BI Stack) on PowerPivotPro here: Table Function

Whew, that's a lot. I hope this helps. Good luck.

Super Contributor

## Re: Create a List of Years

Hi @pierre415,

Based on my test, you should also be able to use the formula(DAX) below to create a new calculate table to make an automated list of past 5 years that updates itself over the years.

```Year =
DISTINCT (
SELECTCOLUMNS (
CALENDAR ( DATE ( YEAR ( TODAY () ) - 4, 1, 1 ), TODAY () ),
"Year", YEAR ( [Date] )
)
)
```

Regards

Regular Visitor

## Re: Create a List of Years

That's awesome, thank you