Forum Discussion
Dynamic Filter on a Date/Time Column?
- 2 years ago
in Power Query you need to use the old school #duration(0,8,0,0)
DateTime.LocalNow()-duration(0,8,0,0)
DAX has a TODAY() function and a NOW function (DAX) - DAX | Microsoft Learn
You would use that in a calculated column (to freeze it at the point of refresh) and do some little date math (subtract 1/3 from it) to get your 8 hr period.
- nrqz2 years agoFrequent Visitor
What I think you're saying is I could create a separate column that contains the date/time values that I want in the 8 hour window, but the rest of the columns wouldn't be filtered on those date/times.
Let me put it another way in SQL Server terms. I'm trying to execute the following query WITHIN Power BI:SELECT * FROM table_name WHERE table_name.the_date > DATE_SUB(NOW(), INTERVAL 8 HOUR)
Is that possible or do I know to pre-prepare the data using an ETL tool before I load it into Power BI in order to pull this off? I know in other BI tools like Tableau doing this is possible, but I'm not as familiar with Power BI.
- lbendlin2 years agoSuper User
but the rest of the columns wouldn't be filteredfilters apply to rows, not columns.
- nrqz2 years agoFrequent Visitor
You're right, I should have said "rows" or "data".
Does the rest of my post above make sense as far as what I'm trying to do? Basically load all data into Power BI, then "pre-filter" that data within Power BI so only the rows connected to the timestamps from the last 8 hours appear.