Forum Discussion

DebbieE's avatar
DebbieE
Icon for Community Champion rankCommunity Champion
6 years ago

M code or DaX to add Flags against specific dates

Really struggling to come up with some Logic

 

Currently In M I have a flag to find all the dates in the previous 3 months

Date.IsInPreviousNMonths(Date.AddMonths([Date], -1), 3))

 

And a Flag to find the date for the month this time last year by doing the following

For the Date I create another column called Month Year, e.g. May 2020

then I created a column for this time last year e.g. May 2019 (Simply by subtracting 1 from year)

 

then I create a conditional column

 

So Simply if they may then I can set the flag

 

With these two flags set I set up another conditional column

 

this totally works. if I drag this flag into filters I can immediately filter a report on the last 3 months AND this time last year (Month)

 

Great, because this is the kind of information that is required in a lot of visuals

 

However, this is all against current date

 

I have been asked, What about if we want to see this information and pretend that April is the current Month (Or obviously any month)

 

Obviously this would require a slicer but I have absolutely no idea how I could do the above logic

 

Could anyone point me in the right direction for this. Im at a bit of a loss at the moment