cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
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
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
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

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
secondImage

Experience what’s next for Power Apps

Join us for an in-depth look at the new Power Apps features and capabilities at the free Microsoft Business Applications Launch Event.

Power Apps Community Call

Power Apps Community Call: February

Did you miss the call? Check out the Power Apps Community Call here.

New Power Super Users

Congratulations!

We are excited to announce the Power Apps Super Users!

New Badges

New Solution Badges!

Check out our new profile badges recognizing authored solutions!

Top Kudoed Authors
Users online (80,483)