cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
pm4698
Helper IV
Helper IV

Combine SP column and custom value in dropdown

Hi there.

 

I am trying to create a dropdown inside a powerapp and have its items to get distinct values from a SP list column but add my own custom values.

 

Tried this:

App->OnStart: ClearCollect(filteringDates,["View all"], Distinct('SP List', Column));

And inside Dropdown->Items: filteringDates.

 

Now, if i put my custom values in front of the distinct inside clearcollect then i get the View all and all the options below but show as blank. If i use the distinct first and later the View all then i get and see all distinct values in drop down but the View all seems blank (but its there).

 

Any ideas?

 

Thank you in advance

1 ACCEPTED SOLUTION

Accepted Solutions
C-Papa
Super User
Super User

If the columns is a date column you have to enter dates, regardless, therefore, you cannot add text values. you could remove the dropdown and use a datepicker or change the datasource column to text and refresh your datasource within your app, it will then accept dates, formatted as text and text and numbers formatted as text. 

View solution in original post

8 REPLIES 8
C-Papa
Super User
Super User

Hi, this should do it, set the dropdown items to filteringDates

 

ClearCollect(filteringDates,Distinct('SP List', Column),{Result:"custom slection"})

@C-Papa  thank you for the fast response. Using your code has an invalid arguments error for ClearCollect

C-Papa
Super User
Super User

you shouldn't have, add a button and change the onselect property to the below but you need to change 'SP List' and Column to your SharePoint list and column. i have just tested it and it works fine

 

code for you

ClearCollect(filteringDates,Distinct('SP List', Column),{Result:"custom selection"})

 

My example in my test

 

ClearCollect(filteringDates,Distinct('Van Usage Log', 'Van Registration Number'),{Result:"custom selection"})

So when I add this code in OnStart event of App i get red lines (error): The given types are incompatible. The function 'ClearCollect' has some invalid arguments.

C-Papa
Super User
Super User

Can you post the exact code you have added to the onstart?

 

I have done the same and you can see it works without issue

 

C-Papa_0-1622112674014.png

 

pm4698
Helper IV
Helper IV

I think the reason may be because collection items need to be of the same type? So my distinct values are actually dates and I am trying to add to this collection a text value (i.e. View All). If this is the case how could i override this?

C-Papa
Super User
Super User

If the columns is a date column you have to enter dates, regardless, therefore, you cannot add text values. you could remove the dropdown and use a datepicker or change the datasource column to text and refresh your datasource within your app, it will then accept dates, formatted as text and text and numbers formatted as text. 

pm4698
Helper IV
Helper IV

@C-Papa thank you. Your code above was correct but as you mentioned you cannot add text values in date data source that's why it wasn't working. What I did is while creating the collection, I used Text() function to convert date to text and add it to the custom value.

 

Thank you

Helpful resources

Announcements
Ignite 2022

WHAT’S NEXT AT MICROSOFT IGNITE 2022

Explore the latest innovations, learn from product experts and partners, level up your skillset, and create connections from around the world.

Power Apps Africa Challenge 2022

Power Apps Africa Challenge

Your chance to join an engaging competition of Power Platform enthusiasts.

Super User 2 - 2022 Congratulations

Welcome Super Users

The Super User program for 2022 - Season 2 has kicked off!

September Events 2022

Check out all of these events

Attend in person or online, there are incredible conferences and events happening all throughout the month of September.

Users online (3,523)