Forum Discussion
Filter calendar table
Good
Currently, we use a calendar table containing years from 1999 to 2100. We have detected that this generates problems when filtering a year, since they come out of the table every year.
I am proposing ways to filter the calendar table, but I would not be able to say which is the most correct and if there would be any better option.
I have contemplated the following cases:
- Case 1: There is only one table of facts:
- Make the filtering of the relationship between the two tables bidirectional.
- From query editor get the first and last dates from the fact table and filter the calendar table by those dates. The latter would not know how to do it, but I think it could, any idea?
- Case 2: There are several tables of facts in the model:
- We cannot put relationships with bidirectional filter in this case.
- Get the maximum and minimum date of all the fact tables in the model, then get the maximum and minimum date of the previous ones, and finally filter the calendar table by those dates. I have to investigate if it can be done. Any ideas?
Could you help me? I think there has to be a simpler and more optimal way to do that.
1 Reply
- v-henryk-mstfCommunity Support
Hi Syndicate_Admin ,
Consider using the FIRSTDATE and LASTDATE functions, the former returning the minimum value of the parameter column in the current filtering context, the latter returning the maximum value (note that the date is represented internally as a floating point number).
Also the best data model needs to be considered. And for Bi-Directional Cross Filter should be used with caution.
Understand star schema and the importance for Power BI - Power BI | Microsoft Docs
Bi-directional Cross Filtering in Power BI: What is it & How does it Work? (powerbiconsulting.com)
If the problem is still not resolved, please provide detailed error information and test data. Looking forward to your reply.
Best Regards,
Henry
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.