cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Andries
Level: Powered On

Functions for code

Good Day i copied some code from a site and it does what I want to a extent. The code generates a calendar and lowers days to be selected and provides a summery Date to Date I want to change the code to exclude weekends from the selection.

 

 

Code : If(!_initialized, UpdateContext({_today:Today()}); UpdateContext({_firstDayOfMonthSmiley Very HappyateAdd(_today,1-Day(_today),Days)}); UpdateContext({_firstDayInViewSmiley Very HappyateAdd(_firstDayOfMonth,-(Mod(Weekday(_firstDayOfMonth)-2,7)+1),Days)}); UpdateContext({_holidays:Table({HolidayDateSmiley Very Happyate(2016,12,25)}, {HolidayDateSmiley Very Happyate(2017,1,1)}, {HolidayDateSmiley Very Happyate(2017,1,16)}, {HolidayDateSmiley Very Happyate(2017,2,20)}, {HolidayDateSmiley Very Happyate(2017,5,29)}, {HolidayDateSmiley Very Happyate(2017,7,4)}, {HolidayDateSmiley Very Happyate(2017,9,4)}, {HolidayDateSmiley Very Happyate(2017,11,23)}, {HolidayDateSmiley Very Happyate(2017,11,24)}, {HolidayDateSmiley Very Happyate(2017,12,25)} ) }); UpdateContext({_initialized:true}) )

 

 

Output button : If( _selectedCount = 1, Text(_selectionStart, DateTimeFormat.ShortDate), _selectedCount = 2, Text(_selectionStart, DateTimeFormat.ShortDate) & " - " & Text(_selectionEnd, DateTimeFormat.ShortDate), "none")

 

 

Now my problem is I am pretty bad on the code side and I have no idea what to do. If I can get guidance on maybe how to fix my issue and maybe more important to my long term ability to use/read/employ code.

1 ACCEPTED SOLUTION

Accepted Solutions
v-zhta-msft
Level 8

Re: Functions for code

Hi @Andries

 

Could you please share more information about your issue especially the mean of “exclude”?

 

Do you want to make the weekends differ from the weekday like using different color?

 

Or do you want to hide the weekends column in you selection?

 

If you just want to make the weekends differ from the weekday like using different circle.

 

Here is the workaround:

 

Change “DaySelectedCircle”  formula as below:

 

8_24.png

RGAB(47,41,43,41) represents the black circle and RGBA(48,128,255,1) represents the blue circle.

 

You can change the color whatever you like.

 

Here are the links about function RGBA() and Weekday():

 

https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/functions/function-colors

 

https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/functions/function-datetime-parts

 

Then you can exclude the weekends with black circle:

2018_8_24_11.png

 

 

Hope this helps you.

 

Best regards,

Zhen

 

 

 

View solution in original post

1 REPLY 1
v-zhta-msft
Level 8

Re: Functions for code

Hi @Andries

 

Could you please share more information about your issue especially the mean of “exclude”?

 

Do you want to make the weekends differ from the weekday like using different color?

 

Or do you want to hide the weekends column in you selection?

 

If you just want to make the weekends differ from the weekday like using different circle.

 

Here is the workaround:

 

Change “DaySelectedCircle”  formula as below:

 

8_24.png

RGAB(47,41,43,41) represents the black circle and RGBA(48,128,255,1) represents the blue circle.

 

You can change the color whatever you like.

 

Here are the links about function RGBA() and Weekday():

 

https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/functions/function-colors

 

https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/functions/function-datetime-parts

 

Then you can exclude the weekends with black circle:

2018_8_24_11.png

 

 

Hope this helps you.

 

Best regards,

Zhen

 

 

 

View solution in original post

Helpful resources

Announcements
firstImage

Microsoft Business Applications Virtual Launch Event

Join us for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

FirstImage

Power Platform World Tour

Coming to a city near you

thirdimage

PowerApps Community User Group Member Badge

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

FourthImage

Join PowerApps User Group!!

Connect, share, and learn with your peers year-round

Top Kudoed Authors
Users Online
Currently online: 84 members 3,814 guests
Please welcome our newest community members: