PowerBI - How to select a specified date range to keep only those rows in PowerBI I want to select a date range from 01/03/24 to 01/04/24 (as an example date range).
I have tried the following.
FILTER(
'formfull',
'formfull'[upLoad_output] >= DATE(2024, 1, 1) && 'formfull'[upLoad_output] <= DATE(2024, 12, 31)
)
This errors to the following.
"Total Literal expected"
Answers
You're trying to use DAX when you need to use M in Power Query. If your column is a date, select the filter in the column header and then between.
It generates code as follows:
= Table.SelectRows(#"Changed Type", each [Date] >= #datetime(2024, 1, 10, 0, 0, 0) and [Date] <= #datetime(2024, 1, 12, 0, 0, 0))
The error message you're encountering suggests that there might be a syntax issue in your DAX expression. The FILTER
function in Power BI expects a table expression as its first argument, but it seems like you're trying to compare individual date values.
To filter rows based on a specified date range, you can use the DATESBETWEEN
function along with the FILTER
function. Here's how you can modify your DAX expression:
FILTER(
'formfull',
DATESBETWEEN('formfull'[upLoad_output], DATE(2024, 1, 3), DATE(2024, 4, 1))
)
In this expression:
'formfull'
is the table you want to filter.DATESBETWEEN
filters dates based on a specified range. It takes three arguments: the column containing dates ('formfull'[upLoad_output]
), the start date (DATE(2024, 1, 3)
), and the end date (DATE(2024, 4, 1)
).
This expression will filter the 'formfull'
table to keep only the rows where the 'upLoad_output'
date falls within the specified range from January 3, 2024, to April 1, 2024. Adjust the dates in the DATE
function as needed to match your desired date range.