Forum Discussion
Filter active records at a specific date
Hello Anonymous,
Using the following DAX function, we can achieve what you want:
IsActive = IF(FIRSTDATE(ALLSELECTED('DTdates'[Date]))<=FIRSTDATE(Table1[ValidFrom]) && LASTDATE(ALLSELECTED('DTdates'[Date]))>=LASTDATE(Table1[ValidTo]) ,1,0)
Here is the required result:
Let me know if I am missing on anything.
Hello Rayulshah!
I'm really appreciate your answer! It seems, it would be perfect solution, however FIRSTDATE and LASTDATE functions are not supported in Direct Query mode.
Is there any possible workaround for this kind of problem?
Thanks,
Matt
- Anonymous8 years agoNot applicable
Anonymous,
Do you connect to SQL Server using Direct Query mode? Could you please post the error message?
Regards,
Lydia - rajulshah8 years ago
Resident Rockstar
Hello Anonymous,
Can you please share which datasource are you using for DirectQuery?
If I may be of some help.
- rajulshah8 years ago
Resident Rockstar
Hello Anonymous,
Can you please try the following DAX formula and see if it works?
IsActive = IF(FIRSTNONBLANK(ALLSELECTED('DTdates'[Date]),'DTdates'[Date])<=FIRSTNONBLANK(Table1[ValidFrom],Table1[ValidFrom]) && LASTNONBLANK(ALLSELECTED('DTdates'[Date]),'DTdates'[Date])>=LASTNONBLANK(Table1[ValidTo],Table1[ValidTo]) ,1,0)
Let me know if it didn't work.
- rajulshah8 years ago
Resident Rockstar
Hello Anonymous,
Let me know if this formula worked or not.
Regards.