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

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
Solution Supplier
Solution Supplier

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
Solution Supplier
Solution Supplier

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
Solution Supplier
Solution Supplier

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
Solution Supplier
Solution Supplier

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 I
Helper I

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
Solution Supplier
Solution Supplier

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

pm4698
Helper I
Helper I

@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
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

secondImage

Demo Extravaganza Winner Announcement

Please join us on Wednesday, July 21st at 8a PDT. We will be announcing the Winners of the Demo Extravaganza!

V3_PVA CAmpaign Carousel.png

Community Challenge - Giveaways!

Participate in the Power Virtual Agents Community Challenge

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Top Solution Authors
Top Kudoed Authors
Users online (2,430)