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

Level up your Power BI skills this month - build one visual each week and tell better stories with data! Get started

Reply
brs09j
Helper II
Helper II

Parameter Scenario - Not sure which route to take

I am currently getting my data from a database connection. I would like the data automatically filtered to have the current year, the current year -1 and the current year +1. So, if I logged in today the filter would include 2016, 2017 and 2018.

I know I can use TODAY ( ), YEAR () and BETWEEN but was wondering what's the best route to go about this in regards to parameters? Do I need to use M in this scenario? I created a table with M using the following

 

let 
 

 Source = #table(  
    {"Year"},  
      {  
          {2015},
          {2016},  
          {2017},
          {2018}  
      }) 


in 

    Source

 

 

 

I wasn't sure if you can only use M to update a table/query created using M

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Yep, M is just fine for something like this. Here's a quick stab; there might be a cleaner way to write it.

 

Last year, this year, and next yearLast year, this year, and next year

I started with a blank query and just wrote the first line. The next two are autogenerated by the GUI after I converted to table and renamed the column. You could leave this as a list if you're using it in other M queries.

 

let
    Source = List.Transform({-1..1}, each Date.Year(Date.AddYears(DateTime.LocalNow(), _))),
    #"Converted to Table" = Table.FromList(Source, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
    #"Renamed Columns" = Table.RenameColumns(#"Converted to Table",{{"Column1", "Year"}})
in
    #"Renamed Columns"

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

Yep, M is just fine for something like this. Here's a quick stab; there might be a cleaner way to write it.

 

Last year, this year, and next yearLast year, this year, and next year

I started with a blank query and just wrote the first line. The next two are autogenerated by the GUI after I converted to table and renamed the column. You could leave this as a list if you're using it in other M queries.

 

let
    Source = List.Transform({-1..1}, each Date.Year(Date.AddYears(DateTime.LocalNow(), _))),
    #"Converted to Table" = Table.FromList(Source, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
    #"Renamed Columns" = Table.RenameColumns(#"Converted to Table",{{"Column1", "Year"}})
in
    #"Renamed Columns"

@Anonymous

 

Thanks! I appreciate your time!

brs09j
Helper II
Helper II

bump

Helpful resources

Announcements
April Power BI Update Carousel

Power BI Monthly Update - April 2026

Check out the April 2026 Power BI update to learn about new features.

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.