March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early bird discount ends December 31.
Register NowBe one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now
Hi there,
I want to filter based on date ranges according to this logic:
'Work'[Start Date] <= MAX('Calendar'[Date])
&& 'Work'[End Date] >= MIN('Calendar'[Date])
Originally using a date between splicer did not work, so I had to use a dax measure as a filter:
Filter Measure =
IF(
NOT ISEMPTY(
FILTER(
'Work',
'Work'[Start Date] <= MAX('Calendar'[Date])
&& 'Work'[End Date] >= MIN('Calendar'[Date])
)
),
1
)
However, the dax measure provides extremely slow performance, to the point where the visuals cannot be displayed. Though, the splicer performed faultlessly (except the fact it was not how I wanted to filter by). Note, I am working with 300k rows of data.
Is there any way I can achieve my desired filter with good performance?
Hi @haichenhuang ,
Please try this measure:
Filter Measure 2 =
VAR __min_date = MIN('Calendar'[Date])
VAR __max_date = MAX('Calendar'[Date])
VAR __cur_start_date = SELECTEDVALUE('Work'[Start Date])
VAR __cur_end_date = SELECTEDVALUE('Work'[End Date])
VAR __filter = IF(__cur_start_date>=__min_date && __cur_end_date<=__max_date,1)
RETURN
__filter
Best Regards,
Gao
Community Support Team
If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!
How to get your questions answered quickly -- How to provide sample data in the Power BI Forum -- China Power BI User Group
Ok, if that is your requirement, fine.
What is it that you are trying to calculate? Could you please explain the logic of what you would like to calculate with that, then we can check if the calculation you want originally was actually logically correct and can find the solution to optimize it.
Okay, so the objective is to display in a table the work items ( 'Work') that are relevant in a given date range. I have a Calendar table for the dates in a splicer. What I mean by relevant is if the the start or end dates of the work item occurs anytime in the given date range. From this I've thought the logic to be if the Work start date is less than the given end date, and the work end date is greater than the given start date:
'Work'[Start Date] <= MAX('Calendar'[Date])
&& 'Work'[End Date] >= MIN('Calendar'[Date])
So in the table, i've inserted Filter Measure (see orig. post) into the Filter section, and show if Filter mEasure = 1. Where the table has columns related to 'Work' table.
Hi, why the original slicer didnt work?
in you original confition, it has to be
'Work'[Start Date] >=Min('Calendar'[Date])
&& 'Work'[End Date] <= Max('Calendar'[Date])
Because I don't want the slicer to perform as:
'Work'[Start Date] >=Min('Calendar'[Date])
&& 'Work'[End Date] <= Max('Calendar'[Date])
Rather, I want it to do the following - note how it is different:
'Work'[Start Date] <= MAX('Calendar'[Date])
&& 'Work'[End Date] >= MIN('Calendar'[Date])
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
User | Count |
---|---|
91 | |
90 | |
83 | |
73 | |
49 |
User | Count |
---|---|
167 | |
149 | |
98 | |
73 | |
57 |