//Power BI M Script. Create a new blank query, and in the advanced editor paste this over the exisitng code let #"CSG Pro Relative Date Generator" = "For more info visit us at www.csgpro.com", #"Instructions" = Table.FromColumns({{ "This is a lookup table for adding relative dates to an existing date table. It might be helpful to copy these instruction into Notepad or MS Word. To do that, on the top left corner of this table is a little table shaped button, click on it and hit Copy Entire Table. Paste it wherever is most convenient. ", "First set what dates should be included in the table by clicking on the gear next to ""SET START AND END --->"". Once there you can just type in the start and end dates. (It's best to go a year or so beyond what you need.) ", "On the right of the screen, above ""Applied Steps"" change the Name to ""LutRelativeDates"" (or whatever name you like) ", "Just above Applied Steps and Below the Name is a link for All Properties; click on it and in the dialogue that pops up uncheck ""Enable Load to Report"" ", "Then go back to your calendar table and on the Home ribon click Merge Queries, and select this query as the second table. Click on the date column on both tables then hit OK. ", "On the new column, the top right corned will become an expand button; click on it, then in the new drop down uncheck ""Use Column Name as Prefix"". ", "Next uncheck any columns you don't want to add, then click OK. ", "In the Home Ribbon hit Close and Apply.", "Now go to your Calendar table, and make sure all of the numeric index coluns have a date type of ""Number"" (it needs to not be text.) ", "Then for each index label column, click on the column, and under Modeling set the Sort By to the numeric equivelant; (Sorting ""Relative Year Index Label"" by ""Relative Year Index"", ""Relative Month Index Label"" by ""Relative Month Index"" and so on.) ", "Once, you're done with that your free to use the columns however you like, including in slicers and page level filters. " }}, {"Steps"} ), #"DateGenerator (Ignore Me)" = (StartDate, EndDate ) => Table.FromColumns( { List.Dates( Date.From( StartDate ), Number.From( Date.From( EndDate ) - Date.From( StartDate ) ), #duration(1,0,0,0) ) }, { "Date"} ), #"SET START AND END --->" = #"DateGenerator (Ignore Me)"(#date(2000, 1, 1), #date(2020, 12, 31)), #"Add System Date" = Table.AddColumn(#"SET START AND END --->", "System Date", each Date.From( DateTime.FixedLocalNow() )), #"Add Relative Year Index" = Table.AddColumn(#"Add System Date", "Relative Year Index", each Date.Year( [Date] ) - Date.Year( [System Date] )), #"Add Relative Month Index" = Table.AddColumn(#"Add Relative Year Index", "Relative Month Index", each [Relative Year Index] * 12 + ( Date.Month( [Date] ) - Date.Month( [System Date] ) )), #"Add Relative Day Index" = Table.AddColumn(#"Add Relative Month Index", "Relative Day Index", each Number.From( [Date] - [System Date] )), #"Add Relative Year Index Label" = Table.AddColumn(#"Add Relative Day Index", "Relative Year Index Label", each if [Relative Year Index] < -1 then Text.From( -1 * [Relative Year Index] ) & " Years Back" else if [Relative Year Index] > 1 then Text.From( [Relative Year Index] ) & " Years Forward" else if [Relative Year Index] = -1 then "Last Year" else if [Relative Year Index] = 0 then "Current Year" else if [Relative Year Index] = 1 then "Next Year" else "Error"), #"Add Relative Month Index Label" = Table.AddColumn(#"Add Relative Year Index Label", "Relative Month Index Label", each if [Relative Month Index] < -1 then Text.From( -1 * [Relative Month Index] ) & " Months Back" else if [Relative Month Index] > 1 then Text.From( [Relative Month Index] ) & " Months Forward" else if [Relative Month Index] = -1 then "Last Month" else if [Relative Month Index] = 0 then "Current Month" else if [Relative Month Index] = 1 then "Next Month" else "Error"), #"Add Relative Day Index Label" = Table.AddColumn(#"Add Relative Month Index Label", "Relative Day Index Label", each if [Relative Day Index] < -1 then Text.From( -1 * [Relative Day Index] ) & " Days Back" else if [Relative Day Index] > 1 then Text.From( [Relative Day Index] ) & " Days Forward" else if [Relative Day Index] = -1 then "Yesterday" else if [Relative Day Index] = 0 then "Today" else if [Relative Day Index] = 1 then "Tomorrow" else "Error"), #"Reordered Columns" = Table.ReorderColumns(#"Add Relative Day Index Label",{"Date", "System Date", "Relative Year Index", "Relative Year Index Label", "Relative Month Index", "Relative Month Index Label", "Relative Day Index", "Relative Day Index Label"}), #"Changed Type" = Table.TransformColumnTypes(#"Reordered Columns",{{"Date", type date}, {"System Date", type date}, {"Relative Year Index", Int64.Type}, {"Relative Month Index", Int64.Type}, {"Relative Day Index", Int64.Type}, {"Relative Year Index Label", type text}, {"Relative Month Index Label", type text}, {"Relative Day Index Label", type text}}) in #"Changed Type"