Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Syndicate_Admin
Administrator
Administrator

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 1
v-henryk-mstf
Community Support
Community 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.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.