web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Apps
Answered

Functions for code

(0) ShareShare
ReportReport
Posted on by 20

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({_firstDayOfMonth:DateAdd(_today,1-Day(_today),Days)}); UpdateContext({_firstDayInView:DateAdd(_firstDayOfMonth,-(Mod(Weekday(_firstDayOfMonth)-2,7)+1),Days)}); UpdateContext({_holidays:Table({HolidayDate:Date(2016,12,25)}, {HolidayDate:Date(2017,1,1)}, {HolidayDate:Date(2017,1,16)}, {HolidayDate:Date(2017,2,20)}, {HolidayDate:Date(2017,5,29)}, {HolidayDate:Date(2017,7,4)}, {HolidayDate:Date(2017,9,4)}, {HolidayDate:Date(2017,11,23)}, {HolidayDate:Date(2017,11,24)}, {HolidayDate:Date(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.

Categories:
I have the same question (0)
  • Verified answer
    v-zhta-msft Profile Picture
    Microsoft Employee on at

    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

     

     

     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 324 Most Valuable Professional

#2
11manish Profile Picture

11manish 193

#3
Valantis Profile Picture

Valantis 138

Last 30 days Overall leaderboard