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

Calender filtering

(0) ShareShare
ReportReport
Posted on by 174

I have created a custom calendar using gallery, I want to add two dropdowns one for year and other for month and show the days in the gallery based on dropdown selections. the formula for items property in gallery is as follows;

ForAll(
Sequence(42),
{Value: varFirstDayOfMonth + Value - 1 - Weekday(
varFirstDayOfMonth,
StartOfWeek.Sunday
) + 1,
NextDay: varFirstDayOfMonth + Value - 1 - Weekday(
varFirstDayOfMonth,
StartOfWeek.Sunday
) + 2}
)

How to achieve it please help

 

Categories:
I have the same question (0)
  • BCBuizer Profile Picture
    22,800 Super User 2026 Season 1 on at

    Hi @muzamil-baxture ,

     

    Can you please provide a bit more context and perhaps share a screenshot of what you're trying to build? It's not clear from your description.

  • muzamil-baxture Profile Picture
    174 on at

    hi, Below is the screenshot of my calendar please tell me the procedure to add two dropdowns one for year and other for month, based on the selection of years and months from these two dropdowns i want to show the appropriate  days in the calendar please helpCalender screenshot.PNG

     

    Calender screenshot.PNG
  • BCBuizer Profile Picture
    22,800 Super User 2026 Season 1 on at

    Hi @muzamil-baxture ,

     

    I'm asuming you can get the user to see a certain period in the calendar by setting varFirstDayOfMonth, so if you insert the tow dropdowns, you can add a formula to the OnChange property of those controls to set a value for varFirstDayOfMonth, based on the selection of the dropdowns themselves.

  • muzamil-baxture Profile Picture
    174 on at

    i tried inserting two dropdowns and also set the OnChange property to : Set(varFirstDayOfMonth,Date(Year(Dropdown2.Selected.Value), Month(Dropdown1.Selected.Value), 1 ))

    But this isn't working also the Text label which shows the month and the year isn't working properly after selecting the values from the dropdowns...

  • BCBuizer Profile Picture
    22,800 Super User 2026 Season 1 on at

    Hi @muzamil-baxture ,

     

    What is it that's not working? What output are you receiving vs. what you are actually getting? 

     

     

  • muzamil-baxture Profile Picture
    174 on at

    Hi @BCBuizer ,

    The issue is that whenever I am running the app and the moment i change the values from my dropdowns for example i select the year 2024 from my year dropdown and Jan from my month dropdown the label which shows the year and month just above the calendar doesn't change. For the reference i have created this whole screen from this blog https://www.matthewdevaney.com/make-a-calendar-in-power-apps-part-1/ here if you check all the code is there. Please can you just check and let me know how to make the modifications in order to add two dropdowns one for month and other for year and use them, what properties should i set for these two dropdowns like onchange, default, items etc. I really appreciate your help. 

  • BCBuizer Profile Picture
    22,800 Super User 2026 Season 1 on at

    Hi @muzamil-baxture ,

     

    From what I can see you have the correct formula for the OnChange property of the dropdowns so this may work. However, I assume (to be confirmed by error messages from you) this is not working because the selected items are not recognized by the formula.

     

    What is the value of the variable before and after changing the selection in either of the dropdowns?

  • muzamil-baxture Profile Picture
    174 on at

    Hey @BCBuizer, I actually deleted those dropdowns as it was not working. What actually i want is to please tell me the complete procedure to achieve this by inserting two new dropdowns into the screen, as i hope you might have visited the link above from there you can get to see the values of the variables

  • BCBuizer Profile Picture
    22,800 Super User 2026 Season 1 on at

    Hi @muzamil-baxture ,

     

    If you look at the Items property of the gallery, you can see that 42 items are created (corresponding with the 42 cells in the gallery) and then populated, based on the value of varFirstDayOfMonth:

    ForAll(
     Sequence(42),
     varFirstDayOfMonth
     +Value-Weekday(varFirstDayOfMonth, StartOfWeek.Sunday)
    )

     

    So whatever change you make to this variable will update what you see in the gallery. This is for instance demonstrated by the formula to go to the next month where the value for Month is increased by 1:

    BCBuizer_0-1675768432857.png

     

    So with your DropDowns you were already a long way there, just you need to make sure the OnChange property is "compatible" with the items in your (month)dropdown. Month names may pose an issues, whereas numbers will probably work:

    drpMonth.Items = Sequence(12)
    drpMonth.Default = Month(varFirstDayOfMonth)
  • Verified answer
    muzamil-baxture Profile Picture
    174 on at

    Hi @BCBuizer ,

    I finally figured out the logic and my app is working perfectly. First I inserted two dropdowns one for year and another of month named Dropdown1 and Dropdown2 respectively.

    For Dropdwn1 the properties I set were - Items : [2010,2011,2012,2013,2014,2015,2016,2017,2018,2019,2020,2021,2022,2023,2024,2025,2026,2027,2028,2029,2030]

    Default : Year(varFirstDayOfMonth),

    Onchange : Set(varFirstDayOfMonth,
    Date(
    Self.Selected.Value,
    Month(varFirstDayOfMonth),
    1
    )
    ) Similarly for month dropdown i.e. Dropdown2  - Items : Used collection on appOnStart for this - ClearCollect(colMonths,{month:"Jan",value:1},{month:"Feb",value:2},{month:"Mar",value:3},{month:"Apr",value:4},{month:"May",value:5},{month:"Jun",value:6},{month:"Jul",value:7},{month:"Aug",value:8},{month:"Sep",value:9},{month:"Oct",value:10},{month:"Nov",value:11},{month:"Dec",value:12})

    Default - LookUp(colMonths,value=Month(varFirstDayOfMonth)).month 

    Onchange - Set(varFirstDayOfMonth,
    Date(
    Year(varFirstDayOfMonth),
    Self.Selected.value,
    1
    )
    ) Also, i had to change the OnSelect properties for previous and next arrows to - Set(varFirstDayOfMonth,
    Date(
    Year(varFirstDayOfMonth),
    Month(varFirstDayOfMonth)-1,
    1
    )
    );Reset(Dropdown1);Reset(Dropdown2), 

    - Set(varFirstDayOfMonth,
    Date(
    Year(varFirstDayOfMonth),
    Month(varFirstDayOfMonth)+1,
    1
    )
    );Reset(Dropdown1);Reset(Dropdown2)

    and finally the OnSelect property of the button which shows Today's text

    as - Set(varFirstDayOfMonth,
    Date(
    Year(Today()),
    Month(Today()),
    1
    )
    );
    Reset(Dropdown1);Reset(Dropdown2)  

    By making these changes now I can select the month and year from the dropdown and easily show the appropriate days in the calendar based on the selection from dropdowns. Also by wiring the header label which shows the name of year and month and the previous & next arrows.

    Calendar updated.PNG

     

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 Launch!

Jump in, show your community spirit, and win prizes!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
Valantis Profile Picture

Valantis 404

#2
timl Profile Picture

timl 344 Super User 2026 Season 1

#3
WarrenBelz Profile Picture

WarrenBelz 320 Most Valuable Professional

Last 30 days Overall leaderboard