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
Anonymous , Please check if my blog and video on the same topic can help
Power BI: HR Analytics - Employees as on Date : https://youtu.be/e6Y-l_JtCq4
Power BI HR Active Employee Tenure Bucketing, and Hired, Terminated, and Active employees: https://youtu.be/fvgcx8QLqZU
Thank you for your response. Unfortunately I think it doesn't help me with my problem at all. At least I don't get how it would help me. 😕
- amitchandak1 year ago
Super User
Anonymous , if you need Active between dates, or based on start date and end date it will help. I am attaching the files where this has been done in two manners
- Anonymous1 year agoNot applicable
Hi. Nope. Still not understand. Your slicer 'between' has same problem than I have:
For example see the picture above - the slicer is between 25.11.2016 and 17.2.2017 and the table still has there dates which aren't between those dates (e.g. Start Date 1.1.2015, End Date null) etc.
Or am I missing something ?