Want to set a default from and to date in the filter as the 1st april of the current financial year to 31st Mar

hi

I want to set the from and date filter parameter as 1st april of the current financial year.

Eg. If today is 31st Mar 2023, the current financial year is 2023. The start date that i want is dynamic and will change based on which financial year we are in today. The end date should be the end of the current financial year. Start date should be 1st Apr 2023 and end date is 31 Mar 2024,

If today is 1st April 2024, then the current financial year is 2024. The start date is 1st apr 2024-31mar 2025. I have set up a measure to determine what is the start date and end date. But how do i incorporate that into the filter.

1 Like

Hello @Xingyin1991, welcome to the QuickSight Community! We could set up a filter to manage this functionality with the use of a calculated field. Basically, we would want to use an ifelse statement to check if a date is from April-December, the year would be the same, but if it is from January-March, it would reference the previous year. I will use calculations like extract and addDateTime to make this functionality. This is how that would look:

ifelse(extract('MM', {date}) >= 4 AND extract('MM', {date}) <= 12, extract('YYYY', {date}),
extract('YYYY', addDateTime(-1, 'YYYY', {date})))

If that date month value isn’t between 4 and 12, then you can use addDateTime to return the Year value for the previous year. Now, each row will have a value linked to the financial year and you can filter by that year.

Let me know if you have any further questions!

1 Like

Hello @DylanM

I actually want the default value of the filters in the control to be by default the start of my organization current financial year and the end date to be the end of the current financial year.

Hello @Xingyin1991, I think I understand. Here is what I think the best route would be. You should create a parameter that is only used to select the Year and default it to the start of this year:


image

Then, you can use a calculated field to return your date values for the financial year depending on the user selection for year.

ifelse(${DateYear} = truncDate('YYYY', {date}) AND extract('MM', {date}) >= 4 OR truncDate('YYYY', addDateTime(1, 'YYYY', ${DateYear})) = truncDate('YYYY', {date}) AND extract('MM', {date}) < 4, {date}, NULL)

This would only allow for a single year to be shown at a time, but it should allow for a dynamic financial year default while checking for the proper months. Let me know if this helps!

3 Likes

Do i enter the calculated fields to replace YYYY in the format control in the picture above? Where do i enter the formula?

Hello @DylanM

I have dataset for donation

Donation ID Donor Name Donation Amount Amount Received Date Donation Date
57163600985 Adeline $203.00 12/8/2025 12/7/2025
50752367267 Adelaide $218.00 12/9/2024 12/9/2024
75388114241 Bonnie $168.00 12/4/2025 12/6/2025
67890901716 Britney $89.00 12/1/2025 12/1/2025
12419690315 Courtney $267.00 12/3/2025 12/6/2025
29878999574 Catherine $193.00 12/2/2025 12/8/2025
39322136167 Devin $113.00 12/9/2024 12/7/2025
1035821579 David $213.00 12/5/2025 12/8/2024

I have added the filter Amount received date to be the filter. However, I would like the values in the filter to change dynamically depending on what today is.

I would like the datetime value to be changed dynamically depending on what is today’s date. My organization’s financial year is 1st April of calendar year to 31 Mar of the next calendar year.

If today is 31st Mar 2024, I would like the value in A to be 1st Apr 2023 and value in B to be 31 Mar 2024.

If today is 1st April 2024, I would like the value in A to be 1st Apr 2024 and value in B to be 31 Mar 2025.

I have set up two parameters (i.e. startofcurrentFY and endofcurrentfy) and two calculated fields to be used for value A and value B, such that I can use parameters for the filter amount received date to and amount received date from (i.e. A and B)

for value A, the calculated measure startofcurrentFY =
ifelse(
truncDate(‘YYYY’, now()) = ${startofcurrentFY}
AND extract(‘MM’, now()) >= 4
OR
truncDate(‘YYYY’, addDateTime(1, ‘YYYY’, ${startofcurrentFY})) = truncDate(‘YYYY’, now())
AND extract(‘MM’, now()) < 4,
parseDate(concat(toString(extract(‘YYYY’, now())-1), ‘-04-01’), ‘yyyy-MM-dd’),
parseDate(concat(toString(extract(‘YYYY’, now()) ), ‘-04-01’), ‘yyyy-MM-dd’)
)

for value B, the calculated measure endofcurrentFY =
ifelse(
truncDate(‘YYYY’, now()) = ${endofcurrentfy}
AND extract(‘MM’, now()) >= 4
OR
truncDate(‘YYYY’, addDateTime(1, ‘YYYY’, ${endofcurrentfy})) = truncDate(‘YYYY’, now())
AND extract(‘MM’, now()) < 4,
parseDate(concat(toString(extract(‘YYYY’, now())), ‘-03-31’), ‘yyyy-MM-dd’),
parseDate(concat(toString(extract(‘YYYY’, now())+1 ), ‘-03-31’), ‘yyyy-MM-dd’)
)

Problems:

  1. However when I used the two parameters I have set up in the amount received date filter, i see that it return Null for Amount Received date to and Amount Received from in the control.
  2. When I remove Amount Received date to and from from the filter, and added the parameter to the control, I have to pick a static defult date that does not change dynamically with what today;s date is.

My problem is actualy very similar to the below:
How to make Dynamic parameter - Question & Answer - Amazon QuickSight Community

1 Like

Hello @Xingyin1991, so I think trying to have the parameter dynamically update will be the difficult part and my calculated field can be utilized as a work-around. Rather than the parameter showing the financial year date, like April 1st 2024, it would be easier if the user just selected a year and then you can use the calculated field as the filter.

Depending on the year linked to the date the user selects, the values for that financial year will be returned. I’ll share the QuickSight Arena analysis where I built this solution.

Want to set a default from and to date in the filter

Check my calculated field for Financial Year Filter and the date related filter I applied to the visual to exclude NULL values. Let me know if this helps!

1 Like

Hello @Xingyin1991, since we have not heard back from you with any further questions, I will mark my previous response as the solution. Please let me know if you still need assistance on this topic, and I can guide you further. Thank you!

2 Likes