cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
abd3127 Kudo Kingpin
Kudo Kingpin

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
Power Apps
Power Apps

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
Power Apps
Power Apps

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 Kudo Kingpin
Kudo Kingpin

Re: Achieving fiscal year using datepicker

Thanks @CarlosFigueira

This solution works like a charm!!

 

 

Helpful resources

Announcements
MBAS Gallery 2020

MBAS Gallery 2020

Watch Microsoft Business Applications Summit sessions on-demand.

firstImage

New Ranks and Rank Icons released on April 21!

The time has come: We are finally able to share more details on the brand-new ranks coming to the Power Apps Community!

Power Platform 2020 release wave 1 plan

Power Platform 2020 release wave 1 plan

Features releasing from April 2020 through September 2020

Top Solution Authors
Top Kudoed Authors
Users online (5,749)