Function to find last two years power bi

Hi all,

I have an RFP Date and Campaign Member Create Date. I am trying to show all associated records that fall within the last 2 years of the Campaign Member Create Date.

I have tried to use the Datediff function but it returns integer which is correct but I don’t want to have to filter for the number 0,1,and -1 to get the results.

Do you have any suggestions?
Thank you in advance.

I have found a function within Power Query M, Date.IsInNextNYears

but was wondering what is the equivalent in DAX.

Thank you in advance.

Hi @ysherriff,

The PQ function Date.IsInNextNYears is comparing a date value against the current date value of the system.

If you are leveraging the Extended Date table in your model you could compare against a date in a selected Year offset range using DAX to return a boolean value.

But if your aim is to create a boolean filter column, why not create that in PQ?

I hope this is helpful.

1 Like

Thanks Melissa.

I will go the PQ route but just trying to learn DAX as much as I can and find out how to do alternative solutions within DAX for learning purposes.

Could you give me an example of the offset function? Is the below link from Enterprise DNA a good place to start?

Using The Offset Function In Extended Date Tables (enterprisedna.co)

Much appreciate.