Forum Discussion
country based calendar filter
Hi Team,
I have two filters: Country and Date.
When I select India, the date filter should automatically display the fiscal year range (01-04-2025 to 31-03-2026).
When I select USA, the date filter should display the standard calendar year (01-01-2026 to 31-12-2026)
when India is selected Start date not 31-03-2026
when usa is selected Start date not 31-12-2026
Hi rajasekaro
You can either keep two separate calendar tables and use a field parameter to switch between their columns, or maintain a single table containing two sets of dates and another column to identify the country they are for. In the latter case, because the dates repeat, a many-to-many relationship with the fact tables will likely be necessary. Regardless of the approach, you will need to maintain at least two distinct sets of time intelligence calculations, especially for YTD.
Create a small table that defines the valid ranges per country, then filter measures using that range. Relate: Country[Country] → CountryPeriod[Country] (1:*)
CountryPeriod = DATATABLE( "Country", STRING, "Period", STRING, "StartDate", DATE, "EndDate", DATE, { {"India","FY 2025-26", DATE(2025,4,1), DATE(2026,3,31)}, {"USA", "CY 2026", DATE(2026,1,1), DATE(2026,12,31)} } )Then Apply the range to your measures as:
Sales = VAR s = MIN ( CountryPeriod[StartDate] ) VAR e = MAX ( CountryPeriod[EndDate] ) RETURN CALCULATE ( [Sales], DATESBETWEEN ( 'Date'[Date], s, e ) )If you don’t want to rewrite every measure: use a Calculation Group to wrap SELECTEDMEASURE() with the same DATESBETWEEN() logic, then set the calc item on the page filter.
4 Replies
- cengizhanarslan
Super User
Create a small table that defines the valid ranges per country, then filter measures using that range. Relate: Country[Country] → CountryPeriod[Country] (1:*)
CountryPeriod = DATATABLE( "Country", STRING, "Period", STRING, "StartDate", DATE, "EndDate", DATE, { {"India","FY 2025-26", DATE(2025,4,1), DATE(2026,3,31)}, {"USA", "CY 2026", DATE(2026,1,1), DATE(2026,12,31)} } )Then Apply the range to your measures as:
Sales = VAR s = MIN ( CountryPeriod[StartDate] ) VAR e = MAX ( CountryPeriod[EndDate] ) RETURN CALCULATE ( [Sales], DATESBETWEEN ( 'Date'[Date], s, e ) )If you don’t want to rewrite every measure: use a Calculation Group to wrap SELECTEDMEASURE() with the same DATESBETWEEN() logic, then set the calc item on the page filter.
- danextian
Super User
Hi rajasekaro
You can either keep two separate calendar tables and use a field parameter to switch between their columns, or maintain a single table containing two sets of dates and another column to identify the country they are for. In the latter case, because the dates repeat, a many-to-many relationship with the fact tables will likely be necessary. Regardless of the approach, you will need to maintain at least two distinct sets of time intelligence calculations, especially for YTD.
- v-sgandrathi
Community Support
Hi rajasekaro,
We haven’t heard from you on the last response and was just checking back to see if your query was answered.
Otherwise, will respond back with the more details and we will try to help.
Thank you. - v-sgandrathi
Community Support
Hi rajasekaro,
we haven't heard back from you regarding our last response and wanted to check if your issue has been resolved.
Should you have any further questions, feel free to reach out.
Thank you for being a part of the Microsoft Fabric Community Forum!