cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
abd3127
Level 8

Achieving fiscal year using datepicker

Hi Team,

I have a situation in which i need to enable / disable text input controls depending on the date from datepicker.

 

I have 12 text inputs and a datepicker.

The text inputs expect are according to the 12 months (Jul, Aug, Sep, Oct, ...., Jun)

Now if the month selected in date picker is Aug, then i want my text input for July to be disable.

If December is month selected, the text inputs for Jul, Aug, Sep, Oct, Nov should be disabled.

When i select Jun, all controls except one for Jul should be disabled, I want to achieve this for a fiscal year (Jul 2018 - Jun 2019)

How can i pull this off?

 

Thanks

1 ACCEPTED SOLUTION

Accepted Solutions
PowerApps Staff CarlosFigueira
PowerApps Staff

Re: Achieving fiscal year using datepicker

You'll need to update the DisplayMode property for all individual text input controls, with minor tweaks in the formula for each one.

For the months 1-6 (Jan-Jun), you need to disable the control if the month of the selected date is past that month and it's less than July (otherwise it would be in the next fiscal year). Notice that the expression for June will always evaluate to DisplayMode.Edit (since no integer value can be both greater than 6 and smaller than 7), so you could use that, but I like the consistency.

Jan: If(Month(DatePicker1.SelectedDate) > 1 And Month(DatePicker1.SelectedDate) < 7, DisplayMode.Disabled, DisplayMode.Edit)
Feb: If(Month(DatePicker1.SelectedDate) > 2 And Month(DatePicker1.SelectedDate) < 7, DisplayMode.Disabled, DisplayMode.Edit)
Mar: If(Month(DatePicker1.SelectedDate) > 3 And Month(DatePicker1.SelectedDate) < 7, DisplayMode.Disabled, DisplayMode.Edit)
Apr: If(Month(DatePicker1.SelectedDate) > 4 And Month(DatePicker1.SelectedDate) < 7, DisplayMode.Disabled, DisplayMode.Edit)
May: If(Month(DatePicker1.SelectedDate) > 5 And Month(DatePicker1.SelectedDate) < 7, DisplayMode.Disabled, DisplayMode.Edit)
Jun: If(Month(DatePicker1.SelectedDate) > 6 And Month(DatePicker1.SelectedDate) < 7, DisplayMode.Disabled, DisplayMode.Edit)

For the months 7-12 (Jul-Dec), you would disable the control if the month is less than June or if it's past the selected date. Again, notice that the expression for July could be simplified to 'Month(DatePicker1.SelectedDate) = 7' and for December as 'Month(DatePicker1.SelectedDate) < 7' (since there's no month greater than 12), but again, for consistency I prefer to keep the same expression as the other months.

Jul: If(Month(DatePicker1.SelectedDate) > 7 Or Month(DatePicker1.SelectedDate) < 7, DisplayMode.Disabled, DisplayMode.Edit)
Aug: If(Month(DatePicker1.SelectedDate) > 8 Or Month(DatePicker1.SelectedDate) < 7, DisplayMode.Disabled, DisplayMode.Edit)
Sep: If(Month(DatePicker1.SelectedDate) > 9 Or Month(DatePicker1.SelectedDate) < 7, DisplayMode.Disabled, DisplayMode.Edit)
Oct: If(Month(DatePicker1.SelectedDate) > 10 Or Month(DatePicker1.SelectedDate) < 7, DisplayMode.Disabled, DisplayMode.Edit)
Nov: If(Month(DatePicker1.SelectedDate) > 11 Or Month(DatePicker1.SelectedDate) < 7, DisplayMode.Disabled, DisplayMode.Edit)
Dec: If(Month(DatePicker1.SelectedDate) > 12 Or Month(DatePicker1.SelectedDate) < 7, DisplayMode.Disabled, DisplayMode.Edit)

The attached app shows those expressions in a real app. Hope this helps!

View solution in original post

2 REPLIES 2
PowerApps Staff CarlosFigueira
PowerApps Staff

Re: Achieving fiscal year using datepicker

You'll need to update the DisplayMode property for all individual text input controls, with minor tweaks in the formula for each one.

For the months 1-6 (Jan-Jun), you need to disable the control if the month of the selected date is past that month and it's less than July (otherwise it would be in the next fiscal year). Notice that the expression for June will always evaluate to DisplayMode.Edit (since no integer value can be both greater than 6 and smaller than 7), so you could use that, but I like the consistency.

Jan: If(Month(DatePicker1.SelectedDate) > 1 And Month(DatePicker1.SelectedDate) < 7, DisplayMode.Disabled, DisplayMode.Edit)
Feb: If(Month(DatePicker1.SelectedDate) > 2 And Month(DatePicker1.SelectedDate) < 7, DisplayMode.Disabled, DisplayMode.Edit)
Mar: If(Month(DatePicker1.SelectedDate) > 3 And Month(DatePicker1.SelectedDate) < 7, DisplayMode.Disabled, DisplayMode.Edit)
Apr: If(Month(DatePicker1.SelectedDate) > 4 And Month(DatePicker1.SelectedDate) < 7, DisplayMode.Disabled, DisplayMode.Edit)
May: If(Month(DatePicker1.SelectedDate) > 5 And Month(DatePicker1.SelectedDate) < 7, DisplayMode.Disabled, DisplayMode.Edit)
Jun: If(Month(DatePicker1.SelectedDate) > 6 And Month(DatePicker1.SelectedDate) < 7, DisplayMode.Disabled, DisplayMode.Edit)

For the months 7-12 (Jul-Dec), you would disable the control if the month is less than June or if it's past the selected date. Again, notice that the expression for July could be simplified to 'Month(DatePicker1.SelectedDate) = 7' and for December as 'Month(DatePicker1.SelectedDate) < 7' (since there's no month greater than 12), but again, for consistency I prefer to keep the same expression as the other months.

Jul: If(Month(DatePicker1.SelectedDate) > 7 Or Month(DatePicker1.SelectedDate) < 7, DisplayMode.Disabled, DisplayMode.Edit)
Aug: If(Month(DatePicker1.SelectedDate) > 8 Or Month(DatePicker1.SelectedDate) < 7, DisplayMode.Disabled, DisplayMode.Edit)
Sep: If(Month(DatePicker1.SelectedDate) > 9 Or Month(DatePicker1.SelectedDate) < 7, DisplayMode.Disabled, DisplayMode.Edit)
Oct: If(Month(DatePicker1.SelectedDate) > 10 Or Month(DatePicker1.SelectedDate) < 7, DisplayMode.Disabled, DisplayMode.Edit)
Nov: If(Month(DatePicker1.SelectedDate) > 11 Or Month(DatePicker1.SelectedDate) < 7, DisplayMode.Disabled, DisplayMode.Edit)
Dec: If(Month(DatePicker1.SelectedDate) > 12 Or Month(DatePicker1.SelectedDate) < 7, DisplayMode.Disabled, DisplayMode.Edit)

The attached app shows those expressions in a real app. Hope this helps!

View solution in original post

abd3127
Level 8

Re: Achieving fiscal year using datepicker

Thanks @CarlosFigueira

This solution works like a charm!!

 

 

Helpful resources

Announcements
thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

Top Kudoed Authors (Last 30 Days)
Users online (4,870)