Skip to main content

Notifications

Power Apps - Building Power Apps
Answered

Filter ComboBox by Year and Month

(0) ShareShare
ReportReport
Posted on by 372

Hello, 

 

I have sharepoint list, and it has column 'Target Customer' containing date value (mm/dd/yyyy). I want to filter that column with combobox, but I want to show a date value with format like (mm/yyyy), the list component which has that date (mm/yyyy) will show in gallery. how to do that? 

 

Thank you in advance.

  • firda59 Profile Picture
    firda59 372 on at
    Re: Filter ComboBox by Year and Month

    Hi @WarrenBelz 

     

    thankyou! it works now, I wrote wrong column name😅

    hv a nice day!

  • Verified answer
    WarrenBelz Profile Picture
    WarrenBelz 145,691 on at
    Re: Filter ComboBox by Year and Month

    @firda59 ,

    That is strange as it works fine in my testing - below is a better version with applies Distinct to the MM/YYYY format rather than the full date

    Distinct(
     AddColumns(
     SPList,
     "MonthYear",
     Text(
     'Target Customer',
     "mm/yyyy"
     )
     ),
     MonthYear
    )

    Test result below

    WarrenBelz_0-1690091434591.png

    WarrenBelz_1-1690091461372.png

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

    MVP (Business Applications)   Visit my blog Practical Power Apps

     

     

  • firda59 Profile Picture
    firda59 372 on at
    Re: Filter ComboBox by Year and Month

    Hi @WarrenBelz 

     

    Not error, but show nothing.

    This is my SP list

    firda59_0-1690081767654.png

     

    This is my Apps

    firda59_1-1690081811223.png

     

    Do you know how to fix it? Thank you

  • WarrenBelz Profile Picture
    WarrenBelz 145,691 on at
    Re: Filter ComboBox by Year and Month

    @firda59 ,

    In the Combo Box Items

    AddColumns(
     RenameColumns(
     Distinct(
     SPList,
     'Target Customer'
     ),
     "Value",
     "Dates"
     ),
     "Value",
     Text(
     Dates,
     "mm/yyyy"
     )
    )

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

    MVP (Business Applications)   Visit my blog Practical Power Apps

  • firda59 Profile Picture
    firda59 372 on at
    Re: Filter ComboBox by Year and Month

    Hi @Rajkumar_404 

     

    it error, do you know how to fix it?

    firda59_0-1690022896323.png

    Thank you

  • firda59 Profile Picture
    firda59 372 on at
    Re: Filter ComboBox by Year and Month

    Hi @WarrenBelz 

     

    Thank you, 

     

    but do you know how to display (mm/yyyy) format in combobox?

  • Rajkumar_404 Profile Picture
    Rajkumar_404 557 on at
    Re: Filter ComboBox by Year and Month

    Hi

    • Add a ComboBox to your screen and set its Items property to the distinct values of the 'Target Customer' column in your SharePoint list. You can use the Distinct function to get the unique values of the column:
                Distinct('Your SharePoint List', 'Target Customer')
    • Set the ComboBox's DisplayFields property to the following formula to display the date value in the desired format:
                Text(Value, "[$-en-US]mm/yyyy") 

           Replace "Value" with the name of the column that contains the date value.

    • Add a Gallery to your screen and set its Items property to the filtered results of your SharePoint list based on the selected value in the ComboBox. You can use the Filter function to filter the list based on the selected value:
             Filter('Your SharePoint List', 'Target Customer' = ComboBox1.Selected.Value)

             Replace "ComboBox1" with the name of your ComboBox.

    • Add the desired controls to your Gallery to display the filtered results.
      With these steps, you can filter your SharePoint list column with a ComboBox and display the date value in the desired format. The Gallery will display the filtered results based on the selected value in the ComboBox.

      Thanks!

      If my response has been helpful in resolving your issue, I kindly request that you consider clicking "Accept as solution" and "giving it a thumbs up" as a token of appreciation.
  • WarrenBelz Profile Picture
    WarrenBelz 145,691 on at
    Re: Filter ComboBox by Year and Month

    Hi @firda59 ,

    Assuming you have the combo box Items displaying mm/yyyy and I have also assumed an output of .Value for it,

    then the filter would be something like

    Filter(
     AddColumns(
     SPList,
     "TargetMY",
     Text('Target Customer', "mm/yyyy")
     ),
     TargetMY = YourComboBox.Selected.Value
    )
     

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

    MVP (Business Applications)   Visit my blog Practical Power Apps

     

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

Microsoft Kickstarter Events…

Register for Microsoft Kickstarter Events…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Announcing Forum Attachment Improvements!

We're excited to announce that attachments for replies in forums and improved…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 145,691

#2
RandyHayes Profile Picture

RandyHayes 76,287

#3
Pstork1 Profile Picture

Pstork1 65,019

Leaderboard