cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anonymous
Not applicable

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

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

Anonymous
Not applicable

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
dinusc
Microsoft
Microsoft

Hello @Anonymous 

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.

Anonymous
Not applicable

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.

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

Anonymous
Not applicable

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.

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. 

Anonymous
Not applicable

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

Thank you, Thomas_B, for sharing your solution.

Helpful resources

Announcements
PA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

R2 (Green) 768 x 460px.png

Microsoft Dynamics 365 & Power Platform User Professionals

DynamicsCon is a FREE, 4 half-day virtual learning experience for 11,000+ Microsoft Business Application users and professionals.

Users online (1,340)