cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
JR-BejeweledOne
Super User
Super User

Set Variable to filtered value

I am a little lost with this one.   I have a SharePoint list data source that contains Countries along with their associated region and country code.

 

The user selects the region from a dropdown and then selects the country from a 2nd dropdown that has been filtered by the region.  This part is working fine.

 

The next step is to have the OnChange of the Country dropdown set a Variable containing the country code for the selected country so it can be populated into a label.

 

I am struggling with the proper syntax to collect the country code for the selected country.   This was SO much easier in InfoPath  🙃

 

CountryList.pngFields.png

Any help would be appreciated.   

 

 



If you like this post, give it a Thumbs up. If it answered your question, Mark it as a Solution to enable other users find it.
1 ACCEPTED SOLUTION

Accepted Solutions

oh.. that is my bad if that is the case here is the code block for that.

 

 

UpdateContext({varCountryCode:Lookup(Sharepointlist,(country=dropdowncountry.selected.value),CountryCode)})

 

Now you set this variable back to the label.

 

I hope this resolved your issue if you see any challenge let me know I am always happy to help.

Regards,

Krishna
If this post helps, then please consider Accept it as the solution and give thumbs-up to help the other members find it more.


I hope this resolved your issue if you see any challenge/need further help please let me know I am always happy to do it for my community.

Regards,
KrishnaV
Business Applications MVP, Microsoft Certified Trainer
Twitter | Linkedin | YouTube | GitHub
If this post helps you give a and if it solved your issue consider Accept it as the solution to help the other members / new members of the community.

View solution in original post

6 REPLIES 6
KrishnaV
Community Champion
Community Champion

hi @JR-BejeweledOne,

 

It is much easier in PowerApp also, here is the code for that.

Step1: for dropdown Onselect event: updatecontext({varSelectCountry:dropdowncountry.selected.value})

Step 2: set this variable for label Text property varSelectCountry

 

Boom you can see the selected country.

 

I hope this resolved your issue if you see any challenge let me know I am always happy to help.

Regards,

Krishna
If this post helps, then please consider Accept it as the solution and give thumbs-up to help the other members find it more.

 

 


I hope this resolved your issue if you see any challenge/need further help please let me know I am always happy to do it for my community.

Regards,
KrishnaV
Business Applications MVP, Microsoft Certified Trainer
Twitter | Linkedin | YouTube | GitHub
If this post helps you give a and if it solved your issue consider Accept it as the solution to help the other members / new members of the community.
eka24
Super User
Super User

Show the items on the dropdown will help.

But try:

Set(Myselected,Dropdown1.Selected.Value )

Or

 

Set(Myselected,Dropdown1.Selected.Result)

 

Or

Set(Myselected,Dropdown1.Selected.ColumName)

------------

If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users find it.

Sorry that's not what I am trying to do.   If you look at the list there are 3 columns of data.  Region, Country and CountryCode.

 

I have the Region and then the Country in the dropdowns.   I need to set the Variable to the country code for the selected country.

 

Thank you



If you like this post, give it a Thumbs up. If it answered your question, Mark it as a Solution to enable other users find it.

This is not what I am trying to do.   I already have the correct values for the dropdowns working fine.   My list has 3 columns as you can see, Region, Country and Country code.

 

The user selects the Region from the dropdown and then selects a country from the Country dropdown.  The country dropdown is filtered by the Region that is selected in the Region dropdown.   Once the Country is selected, I need to populate a variable with the Country Code.

 

What I don't know how to do is property format the command to filter the country code from the selected country in this particular scenario.

 



If you like this post, give it a Thumbs up. If it answered your question, Mark it as a Solution to enable other users find it.

oh.. that is my bad if that is the case here is the code block for that.

 

 

UpdateContext({varCountryCode:Lookup(Sharepointlist,(country=dropdowncountry.selected.value),CountryCode)})

 

Now you set this variable back to the label.

 

I hope this resolved your issue if you see any challenge let me know I am always happy to help.

Regards,

Krishna
If this post helps, then please consider Accept it as the solution and give thumbs-up to help the other members find it more.


I hope this resolved your issue if you see any challenge/need further help please let me know I am always happy to do it for my community.

Regards,
KrishnaV
Business Applications MVP, Microsoft Certified Trainer
Twitter | Linkedin | YouTube | GitHub
If this post helps you give a and if it solved your issue consider Accept it as the solution to help the other members / new members of the community.

Thank you.  That worked.   I haven't used the Update Context function yet, so this is very helpful.



If you like this post, give it a Thumbs up. If it answered your question, Mark it as a Solution to enable other users find it.

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 (1,733)