Forum Discussion

DavidGorgan's avatar
DavidGorgan
Regular Visitor
5 years ago

Conditional Column - PowerQuery - Detect if date is in the last 7 or 30 days

Hello,

 

I have a table that contains a date column ( [time_recorded]).

 

I'm currently trying to create a conditional column that will display the following values ("Past week", "Past Month", "Other").

 

I've tried the following formula:


= Table.AddColumn(#"Expanded bi sites", "period", each if  Date.IsInPreviousNDays([time_record], 7) = true then "Past 7 Days" else if Date.IsInPreviousNDays([time_record], 30) = true then "Past 30 Days" else "Other Period")

 

 

Please can someone advise?