Forum Discussion
SQL Statement Variable Date Range
- 6 years ago
Hi wasonj1 ,
In Power Query, you can add a custom step to filter by an automatic date range:= Table.SelectRows(#"Name of Previous Step", each [DateColumn] >= Date.AddYears(Date.From(DateTimeZone.LocalNow()), -2))In SQL, you can use just filter by dates using the SQL syntax. I am not very familiar with SQL but the code should be something like this:
WHERE M.Response_Date >= DATEADD(YEAR, -2, GETDATE())or perhaps
WHERE M.Response_Date >= DATEADD(YEAR, -2, TODAY()) - 6 years ago
Hi wasonj1 ,
You could try to refer to danextian 's suggestions, or you also could refer to Pass-parameter-to-SQL-Queries-statement-using-Power-BI for details.
Best Regards,
Zoe ZhiIf this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi wasonj1 ,
In Power Query, you can add a custom step to filter by an automatic date range:
= Table.SelectRows(#"Name of Previous Step", each [DateColumn] >= Date.AddYears(Date.From(DateTimeZone.LocalNow()), -2))
In SQL, you can use just filter by dates using the SQL syntax. I am not very familiar with SQL but the code should be something like this:
WHERE M.Response_Date >= DATEADD(YEAR, -2, GETDATE())or perhaps
WHERE M.Response_Date >= DATEADD(YEAR, -2, TODAY())