cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
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
Highlighted
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
Highlighted
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

Highlighted
Kudo Kingpin
Kudo Kingpin

Re: Achieving fiscal year using datepicker

Thanks @CarlosFigueira

This solution works like a charm!!

 

 

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

Power Platform ISV Studio

Power Platform ISV Studio

ISV Studio is designed to become the go-to Power Platform destination for ISV’s to monitor & manage published applications.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Tech Marathon

Maratón de Soluciones de Negocio Microsoft

Una semana de contenido con +100 sesiones educativas, consultorios, +10 workshops Premium, Hackaton, EXPO, Networking Hall y mucho más!

Top Solution Authors
Top Kudoed Authors
Users online (6,416)