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

lookup with global variable

Hello,

I'm new here and also new to powerapps.

I made buttons where you can select your language. The variable "languageuser" is then set to the chosen language. 

In the next screen I want to search the word in the chosen language in my sheet, so that i don't have to make different screens for every language.

So the text of my button on screen2 should be e.g. "dolor" if you chose spanish. So I used lookup(sheet1;english="pain";languageuser). But this gives me the answer "spanish" which is the text of the variable languageuser.

If I use lookup(sheet1;english="pain";spanish) it works perfectly fine and gives me dolor.

I don't understand why there's a difference when languageuser=spanish?

 

Thank you very much,

Alex

3 REPLIES 3
eka24
Super User
Super User

The difference is that:

languageuser is not a column in your table

spanish? is a column in your Table.

 

Can you explain further. If possible show table columns

 

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.

 

alex13
Regular Visitor

Thank you for your answer!

I attached some screenshots.

I just wonder why it works when i write "espagnol" but when i use languageuser which is set to "espagnol" it doesn't work.

Is there any solution to it?

 

The main goal is to make the text of the buttons depending on the language you chose before, so that i dont have to make a new screen for every language someone might choose.

 

I hope that it is more clear now.

Hi Alex

Welcome to the forums and to PowerApps.

With the Lookup function, it isn't possible to refer to a column name with a variable.

A workaround would be to use the switch function like so:

Switch(languageuser
       espagnol;
       LookUp(sheet1;english="pain";espagnol)
       francais;
       LookUp(sheet1;english="pain";francais)
)

 

There's a post in the ideas forum about this that you can vote on.

https://powerusers.microsoft.com/t5/Power-Apps-Ideas/LookUp-function-reference-column-name-by-a-glob... 

To clarify the way that the LookUp function works, the third argument defines a formula that returns a single value output.

For example, you could write a formula that looks like this:

LookUp(sheet1;
       english="pain";
       "Spanish:" & espagnol & ", French:" & francais
)

Given your spreadsheet, this would produce the following result:

Spanish:dolor, French: fgj

By extension of this logic, hopefully you can see that if languageuser is a variable that is set to espagnol, the following function would produce 'espagnol'.


LookUp(sheet1;english="pain";languageuser )

 

Let us know if you require any further clarification.

Helpful resources

Announcements
User Group Leader Meeting January 768x460.png

Calling all User Group Leaders!

Don't miss the User Group Leader meetings on January, 24th & 25th, 2022.

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

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