cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
tdupton
Level: Powered On

DropDown Default Value

So..I know this must be something simple, but I can't figure it out.  I want to set the default selected value on an edit form for an employee. 

 

Dropdown items come from a SQL Azure table (dbo.Units which has 2 fields UnitID & UnitName).

Dropdown.Items = '[dbo].[Units]'

Dropdown.value=UnitName

Dropdown.default - LookUp('[dbo].[Units]',UnitID=ThisItem.UnitID,UnitName)

 

Why doesn't this select the right unit name?  It always returns the first unit in the table.

 

17 REPLIES 17
Sienna
Level 10

Re: DropDown Default Value

You have to specify row of the table you want to have selected as default in dropdown and not specific column. Use
First('[dbo].[Units]') // for firt line
First(Filter('[dbo].[Units]', UnitID=2)) // for row with UnitID = 2
tdupton
Level: Powered On

Re: DropDown Default Value

Thanks.  That still doesn't select the correct value:

 

First(Filter('[dbo].[Units]',UnitID=ThisItem.UnitID)).UnitName

 

I've tried putting this on the default for the datacard and the dropdown control itself.  Neither work.

Sienna
Level 10

Re: DropDown Default Value

I said do not specify column! Use this

First(Filter('[dbo].[Units]',UnitID=ThisItem.UnitID))
tdupton
Level: Powered On

Re: DropDown Default Value

You have to specifiy a column.  If not, you get an error saying it's expecting a number but getting a record instead.

Sienna
Level 10

Re: DropDown Default Value

Can you post a screenshot of that error with the code
tdupton
Level: Powered On

Re: DropDown Default Value

Capture.PNG

Sienna
Level 10

Re: DropDown Default Value

Hmm... you’re right.. As far as I remember I used to specify row in default of dropdown. However I have just tested it with column and it worked so your code should work just fine

First(Filter('[dbo].[Units]',UnitID=ThisItem.UnitID)).UnitName
Sienna
Level 10

Re: DropDown Default Value

In this case you can try to chage it to only

ThisItem.UnitID
Sienna
Level 10

Re: DropDown Default Value

One more thing... what is in your datacard Items property where you have yor dropdown?

Helpful resources

Announcements
thirdimage

Power Apps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

SecondImage

Difinity Conference

The largest Power BI, Power Platform, and Data conference in New Zealand

Top Solution Authors
Top Kudoed Authors (Last 30 Days)
Users online (4,705)