cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Altontait
Regular Visitor

Get Values from two dropdown Fields

Hi All,

I would really appreciate any help because i really need to get this done. 

I have two dropdown fields in PowerApps each pulling from a SharePoint list(mileage_distance).  Both dropdowns store the same location and I want if a user selects a location in dropdown 1 and another location in dropdown 2, that a third field (text field) shows the distance between those two locations. The distance is also from the mileage_distance list

 

Please see attached milage_distance excel doc attached as well as a preview of my app.

Altontait_1-1626466121832.png

Thanks for your assistance,

Alton

 

2 ACCEPTED SOLUTIONS

Accepted Solutions
WarrenBelz
Super User
Super User

Hi @Altontait ,

You cannot do index type queries in Power Apps as you cannot dynamically reference field names - you cannot specify a field name (other than hard-coding it) from a drop-down value (which I assume you manually coded for the top row.

You would either need a table with two fields (place 1 and place 2) then specify each of the combinations of distances or hard-code the second drop-down results in the lookup 

Switch(
   dd.Selected.xxxx,
   "CherryVille,
   Cherryville", 
   "Harwood",
   Harwood
    . . .  . .

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

View solution in original post

@Altontait So you are building a grid with n number of columns and n number of records in the SP List.

The Items Property of the 2 Dropdowns could just be hard coded as columns and rows are fixed (I assume).

Table({Location:"Board Office", "6 Mile",....})

 

The Text property of the Textinput would be (change control names as required),

Switch(dropdown1.Selected.Location,
	"Board Office", LookUp(yourSPList, Title=dropdown2.Selected.Location).'Board Office',
	"6 Mile", LookUp(yourSPList, Title=dropdown2.Selected.Location).'6 Mile',
	.....
	.....
)

 

View solution in original post

7 REPLIES 7
CNT
Super User
Super User

@Altontait What are the column names and data type of the From Location, To Location and Distance columns in the SP List.

 

WarrenBelz
Super User
Super User

Hi @Altontait ,

You cannot do index type queries in Power Apps as you cannot dynamically reference field names - you cannot specify a field name (other than hard-coding it) from a drop-down value (which I assume you manually coded for the top row.

You would either need a table with two fields (place 1 and place 2) then specify each of the combinations of distances or hard-code the second drop-down results in the lookup 

Switch(
   dd.Selected.xxxx,
   "CherryVille,
   Cherryville", 
   "Harwood",
   Harwood
    . . .  . .

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

View solution in original post

Altontait
Regular Visitor

Hi @CNT this is a preview of my SP List

Altontait_0-1626469228257.png

 

@Altontait So you are building a grid with n number of columns and n number of records in the SP List.

The Items Property of the 2 Dropdowns could just be hard coded as columns and rows are fixed (I assume).

Table({Location:"Board Office", "6 Mile",....})

 

The Text property of the Textinput would be (change control names as required),

Switch(dropdown1.Selected.Location,
	"Board Office", LookUp(yourSPList, Title=dropdown2.Selected.Location).'Board Office',
	"6 Mile", LookUp(yourSPList, Title=dropdown2.Selected.Location).'6 Mile',
	.....
	.....
)

 

View solution in original post

@Altontait ,

As we have both advised, you will need to hard-code this in some form.

Altontait
Regular Visitor

Hi @CNT @WarrenBelz,

I would like to thank you guys for your assistance with this and I did manage to hard code it and it's working perfectly now. 

 

Thank you guys again.

@Altontait Glad to help!

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

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