1
votes

I have a table in Power BI with the date and I am trying to create a calculated column that indicates if that date is within the last 7 days. I understand the syntax of the IF statement, but am having trouble with the actual time calculation. Can anyone assist?

1
Can you give an example of what your table looks like and what you want your calculated column to look like?Alexis Olson

1 Answers

1
votes

Use the DATEDIFF function to reliably determine the number of days (or weeks, or months, or years) between two dates:

IF(
    DATEDIFF(MyTable[MyDate], TODAY(), DAY) < 7,
    "Within last 7 days",
    "Not within last 7 days"
)