Chris
Chris

Reputation: 303

power bi check if date is the last 12 months

I have a dataset that has a column with dates in this format: 1 January 2018. the dataset can contain any dates, but what I'm looking for is to add a column using DAX, called isLast12Months, to say 1 if that's the case and 0 if not. I tried working with the dateadd() function, but unless I'm looking at less than 12 months, nothing gets filled in. is there a simple way to do this?

thanks

Upvotes: 0

Views: 5202

Answers (1)

OscarLar
OscarLar

Reputation: 1335

This is a calculated column which flags dates closer in time than 365 days back win 1 and all else with 0:

isLast12Months = 
IF(
    [Date] > (TODAY()-365);
    1;
    0
)

Upvotes: 1

Related Questions