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

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
Highlighted
Memorable Member
Memorable Member

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
Highlighted
Helper II
Helper II

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.

Highlighted
Memorable Member
Memorable Member

Re: DropDown Default Value

I said do not specify column! Use this

First(Filter('[dbo].[Units]',UnitID=ThisItem.UnitID))
Highlighted
Helper II
Helper II

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.

Highlighted
Memorable Member
Memorable Member

Re: DropDown Default Value

Can you post a screenshot of that error with the code
Highlighted
Helper II
Helper II

Re: DropDown Default Value

Capture.PNG

Highlighted
Memorable Member
Memorable Member

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
Highlighted
Memorable Member
Memorable Member

Re: DropDown Default Value

In this case you can try to chage it to only

ThisItem.UnitID
Highlighted
Memorable Member
Memorable Member

Re: DropDown Default Value

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

Helpful resources

Announcements
secondImage

Demo-Extravaganza 2020

Check out these cool Power Apps & vote on your favorite!

secondImage

Robotic Process Automation

Let's talk about the solution provided by Microsoft for Robotic Process Automation (RPA)

secondImage

Community Highlights

Check out whats happening in Power Apps

secondImage

Community User Group Member Badges

FIll out a quick form to claim your community user group member badge today!

Top Solution Authors
Top Kudoed Authors
Users online (10,809)