Forum Discussion
Need help with filtering two dates using a single slicer in Power BI
- Anonymous1 year ago
Hi all,thanks for the quick reply, I'll add more.
Hi Anonymous ,
Regarding your question, I don't think there should be a relationship between the fact table and the time dimension table. You seem to have created a table-to-table relationship between the 'Date' column of the fact table and the time dimension table. This will result in only filtering the 'Date' column and not the 'StartDate' & 'EndDate' columns. My suggestion is to remove the relationship between the two tables.
The Table data is shown below:
Use the following DAX expression to create a measure
Measure = VAR _startDate = MIN('DateTable'[Date]) VAR _endDate = MAX('DateTable'[Date]) VAR _factTableDate = SELECTEDVALUE('Table'[Date]) VAR _factTableStartDate = SELECTEDVALUE('Table'[Start Date]) VAR _factTableEndDate = SELECTEDVALUE('Table'[End Date]) RETURN IF( (_factTableDate >= _startDate && _factTableDate <= _endDate) && (_factTableStartDate >= _startDate && _factTableStartDate <= _endDate) && (_factTableEndDate >= _startDate && _factTableEndDate <= _endDate), 1,BLANK() )Power BI automatically hides measure that result in 'Blank', which gives the correct result.
Turn off the 'Text wrap' option in the table visual
Move the mouse over the marker and the '<-||->' symbol will appear, drag it.
Final output
Best Regards
Hi all,thanks for the quick reply, I'll add more.
Hi Anonymous ,
Regarding your question, I don't think there should be a relationship between the fact table and the time dimension table. You seem to have created a table-to-table relationship between the 'Date' column of the fact table and the time dimension table. This will result in only filtering the 'Date' column and not the 'StartDate' & 'EndDate' columns. My suggestion is to remove the relationship between the two tables.
The Table data is shown below:
Use the following DAX expression to create a measure
Measure =
VAR _startDate = MIN('DateTable'[Date])
VAR _endDate = MAX('DateTable'[Date])
VAR _factTableDate = SELECTEDVALUE('Table'[Date])
VAR _factTableStartDate = SELECTEDVALUE('Table'[Start Date])
VAR _factTableEndDate = SELECTEDVALUE('Table'[End Date])
RETURN
IF(
(_factTableDate >= _startDate && _factTableDate <= _endDate) &&
(_factTableStartDate >= _startDate && _factTableStartDate <= _endDate) &&
(_factTableEndDate >= _startDate && _factTableEndDate <= _endDate),
1,BLANK()
)
Power BI automatically hides measure that result in 'Blank', which gives the correct result.
Turn off the 'Text wrap' option in the table visual
Move the mouse over the marker and the '<-||->' symbol will appear, drag it.
Final output
Best Regards