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 ACCEPTED SOLUTION
v-yalanwu-msft
Community Support
Community Support

Hi, @Syndicate_Admin ;

Do you mean filter in power query? if so ,you could set the parameter about min date and max date. then filter by parameter.

vyalanwumsft_0-1656311713081.pngvyalanwumsft_1-1656311742265.pngvyalanwumsft_2-1656311982894.png

https://docs.microsoft.com/en-us/power-query/power-query-query-parameters


Best Regards,
Community Support Team _ Yalan Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

View solution in original post

2 REPLIES 2
v-yalanwu-msft
Community Support
Community Support

Hi, @Syndicate_Admin ;

Do you mean filter in power query? if so ,you could set the parameter about min date and max date. then filter by parameter.

vyalanwumsft_0-1656311713081.pngvyalanwumsft_1-1656311742265.pngvyalanwumsft_2-1656311982894.png

https://docs.microsoft.com/en-us/power-query/power-query-query-parameters


Best Regards,
Community Support Team _ Yalan Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

Thanks a lot!

I don't know why the query parameters don't work for me. Even if I define the query as a list, many times it does not let me select the query in the parameter.

On the other hand, when you select the query, I see that it forces you to put a value to the parameter, that value will be updated with the value resulting from the query?

In the end, I have done it by other means.

I tried with the query defined on this website:

https://excelcute.com/fechas-minimo-maximo-power-query/

This option is very interesting because it allows us to obtain the minimum and maximum dates of all the tables of the model. Unfortunately, I don't know why, but although the queries gave me correct results in the query editor, when I did the data loading into the model, the queries were blank....

Another website I found useful was this:

https://powerbiexpertos.com/power-query/fecha-maxima-de-power-query-de-otra-tabla/

In the end, since the parameters did not work for me, I ended up creating a filter that used the result of the query directly, without the use of parameters.

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.