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.

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',
	.....
	.....
)

 

@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
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

365 EduCon 768x460.png

Microsoft 365 EduCon

Join us for two optional days of workshops and a 3-day conference, you can choose from over 130 sessions in multiple tracks and 25 workshops.

Users online (4,823)