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

Changing Dropdown Value property with a condition

Hi everyone,

 

My apps need to use multiple languages and i'm wondering if something is possible.

 

I have many Dropdown, link with data from SQL tables.

Those tables already contains translation for the languages in different columns.

And i use a global variable, in the app, to know the language my user wants to use.

 

My question is:
    Is it possible to change the Dropdown "Value" property (column of my SQL Table), by a If() or a condition based on my global variable for language ?

For now my workaround as been to create one Dropdown for each language supported, and change visibility.
But multiply control in my application doesn't seems to be a great idea in a long term.

 

Thanks, in advance, for your help.

2 ACCEPTED SOLUTIONS

Accepted Solutions
Highlighted
Microsoft
Microsoft

Re: Changing Dropdown Value property with a condition

I'm sorry for confusion. Let me know if my understanding below is correct.

You have a Table in SQL. You have a DropDown control bound to that table. The table contains columns with values specific to different languages (one per language). You want your DropDown control to provide the proper "Selected" value depending on your "language" global variable which specifies a langiage.

If my understanding is correct then my suggestion is to use the ComboBox control instead (since you mention "Value" I assume you use DropDown and not ComboBox). The ComboBox control will give you the entire record as selected item, not a particular value (see "Selected" for single-select mode and "SelectedItems" for multiple-select mode) . Using a branching logic (Switch of If) you should be able to select the appropriate field from the selected record (ComboBox1.Selected.EngVal for example). 

I hope this helps.

View solution in original post

Highlighted
Resolver II
Resolver II

Re: Changing Dropdown Value property with a condition

I find a turnaround to make the dropdown work like i want !

I write it for other people that might search the same thing.

 

The idea is to add a conditionnal column on the Dropdown "Items":

 

AddColumns(
    Items;
    "ChangingTraductions";
    Switch(
        UserLanguage;
        "English";
        Items_TradEn;
        "French";
        Items_TradFr
    )
)

Then you set the "Value" attribute of the Dropdown on ChangingTraductions.

 

But i will remember to think of the ComboBox in the future, to avoid this kind of manipulation.

 

Have a nice day.

View solution in original post

7 REPLIES 7
Highlighted
Microsoft
Microsoft

Re: Changing Dropdown Value property with a condition

Hello @Thomas_B 

You hsuolw be able to achieve this by using the following formula for your ComboBox Item property: 

Switch(lang, "english", Table.EngColumn, "french", Table.FrenchColumn, "spanish", ...)

In the formula above, "lang" is your global variable that takes "english", "french", and so on values. You can keep adding all the language options to your Switch formula.

Highlighted
Resolver II
Resolver II

Re: Changing Dropdown Value property with a condition

Thank you for your answer @dinusc  and for making me discover again the use of the switch.

 

Unfortunatly, it doesn't solve my problem.

I should mention it before, i already know how to change used column on a Dropdown, when i only want one column.

 

In my case, i want to keep the information of the Dropdown items as records of my table
(because i need the SQL ID of the records with: Dropdown.Selected.ID)


But i can't find a way to keep the records that way and only change the column that is display.

Or if i do, by saying that i only want to keep two columns (the selected language and the ID), i can't control it and it display sometimes the translation and sometimes the ID.

Highlighted
Microsoft
Microsoft

Re: Changing Dropdown Value property with a condition

I'm sorry for confusion. Let me know if my understanding below is correct.

You have a Table in SQL. You have a DropDown control bound to that table. The table contains columns with values specific to different languages (one per language). You want your DropDown control to provide the proper "Selected" value depending on your "language" global variable which specifies a langiage.

If my understanding is correct then my suggestion is to use the ComboBox control instead (since you mention "Value" I assume you use DropDown and not ComboBox). The ComboBox control will give you the entire record as selected item, not a particular value (see "Selected" for single-select mode and "SelectedItems" for multiple-select mode) . Using a branching logic (Switch of If) you should be able to select the appropriate field from the selected record (ComboBox1.Selected.EngVal for example). 

I hope this helps.

View solution in original post

Highlighted
Resolver II
Resolver II

Re: Changing Dropdown Value property with a condition

Sorry for the long delay, I was away for a few weeks.

 

I continue to try with the ComboBox instead of the Dropdown, like you explain too me,

i find a way to make it work.

 

But my app use many Dropdowns and my users are used to them, changing them for ComboBoxes is not an ideal solution for me.

 

What i was hoping for (without knowing it at first), is too have the "DisplayFields" option of the comboBox in the dropdown,

which actually is "Value" but cannot be changed by a condition.

 

Thanks anyway for all your help.

Highlighted
Microsoft
Microsoft

Re: Changing Dropdown Value property with a condition

Unfortunately the DropDown control cannot be used to programmatically select fields. In fact, that control is very limited and should not be used for more complex scenarios. 

Highlighted
Resolver II
Resolver II

Re: Changing Dropdown Value property with a condition

I find a turnaround to make the dropdown work like i want !

I write it for other people that might search the same thing.

 

The idea is to add a conditionnal column on the Dropdown "Items":

 

AddColumns(
    Items;
    "ChangingTraductions";
    Switch(
        UserLanguage;
        "English";
        Items_TradEn;
        "French";
        Items_TradFr
    )
)

Then you set the "Value" attribute of the Dropdown on ChangingTraductions.

 

But i will remember to think of the ComboBox in the future, to avoid this kind of manipulation.

 

Have a nice day.

View solution in original post

Highlighted
Microsoft
Microsoft

Re: Changing Dropdown Value property with a condition

Thank you, Thomas_B, for sharing your solution.

Helpful resources

Announcements
secondImage

Demo-Extravaganza 2020

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

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!

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors
Users online (7,738)