Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago
Solved

Last 3 years from table that's not a date table.

Hi Power Query heroes!   My organisation has a table as attached. I would like to create a cloumn to filter my reports for the last 3 'admission' years. I was thinking of something along the l...
  • Smauro's avatar
    6 years ago

    Hi Anonymous 

    Fixing a little bit artemus' code:

        CurrYear = PreviousStep{[Is Current Admissions Year Flag = "Y"]}[Academic Year],
        LastThree = Table.AddColumn(PreviousStep, "Is in last 3", each 0 <= (CurrYear - [Academic Year]) and (CurrYear - [Academic Year]) < 3, Logical.Type)

    First, computing Current Academic Year only once --> less load

    Second, calling that to create a true/false column.

     

    I wasn't sure if you want current year included or not. If not, you should change the constraints.

     

    Then, you can use this T/F column however you like. Since CurrYear is dynamic, it will change when data changes.