cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Microsoft
Microsoft

How to add default value as "Select a value" to dropdown?

Hi,

How to add default value as "Select Cars" to dropdown

* Dropdown contains data from CDS table, using Name column

* Based on Cars selection, another dropdown values are populating - (in simple its a parent dropdown in Cascading scenario)

* I need both Name and CarId should be available in Value property of Items. Please refer below

 

Durga_1-1605882165090.png

 

Durga_0-1605881743379.png

 

What I tried:

ClearCollect(Collection1,{Name:"Select Cars"});Collect(Collection1,Cars.Name)

But it didn't workout for me. it returns only "Name", need CarId also

 

Any help would be appreciated.

 

Thanks in advance

Durga

 

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Super User III
Super User III

@Durga 

Consider changing your formula to the following:

   ClearCollect(Collection1,{Name:"Select Cars"}, Cars)

This will give you what you are looking for.  You were restricting the items to only include Name.

 

Pro Tip!  You can also skip the collection with the following formula for the items property of your DropDown:

ForAll(Sequence(CountRows(Cars)+1),
    {Name: If(Value=1, "Select Cars", Last(FirstN(Cars, Value-1)).Name,
     carid: If(Value=1, 0, Last(FirstN(Cars, Value-1)).carid
    }
) 

This will give you the values you want with a "Select Cars" as the first item.

 

I hope this is helpful for you.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too!

View solution in original post

2 REPLIES 2
Highlighted
Super User III
Super User III

@Durga 

Consider changing your formula to the following:

   ClearCollect(Collection1,{Name:"Select Cars"}, Cars)

This will give you what you are looking for.  You were restricting the items to only include Name.

 

Pro Tip!  You can also skip the collection with the following formula for the items property of your DropDown:

ForAll(Sequence(CountRows(Cars)+1),
    {Name: If(Value=1, "Select Cars", Last(FirstN(Cars, Value-1)).Name,
     carid: If(Value=1, 0, Last(FirstN(Cars, Value-1)).carid
    }
) 

This will give you the values you want with a "Select Cars" as the first item.

 

I hope this is helpful for you.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too!

View solution in original post

Highlighted

Hi RandyHayes,


Thanks for your reply. Pro tip is working like a charm, end brackets(")") are missing for IF condition.

 

Regards

Durga

 

 

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

News & Announcements

Community Blog

Stay up tp date on the latest blogs and activities in the community News & Announcements.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Community Highlights

Community Highlights

Check out the Power Platform Community Highlights

Top Solution Authors
Top Kudoed Authors
Users online (7,087)