cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
jvila
Level: Powered On

Use a Variable as a Table name

Dear friends,

 

I'm fighting with this dropdown code:

SortByColumns(Filter(TAULA_TUT_3ESO; CLASSE=DataCardValue3.Selected.Value); "COGNOM" ;Ascending)

 

It works perfect but I'm trying to exchange the table name "TAULA_TUT_3ESO" with the variable "taula_id", so I just need to make one screen, and not 10! I cannot do it. I work with excel, not sharepoint :-)

 

Thanks a lot!

1 ACCEPTED SOLUTION

Accepted Solutions
Super User
Super User

Re: Use a Variable as a Table name

@jvila 

 

Can you please use the below expression to set the variable and then use the same in multiple screens:
 
Set(tablenameVar, TAULA_TUT_3ESO) --> This could be done on a button click or on Page Visible.
 
SortByColumns(Filter(tablenameVar; CLASSE=DataCardValue3.Selected.Value); "COGNOM" ;Ascending)
 
Here, tablenameVar is the name of variable that will be used on all the screens.
 
Hope this Helps!
 
If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!
6 REPLIES 6
Super User
Super User

Re: Use a Variable as a Table name

@jvila 

 

Can you please use the below expression to set the variable and then use the same in multiple screens:
 
Set(tablenameVar, TAULA_TUT_3ESO) --> This could be done on a button click or on Page Visible.
 
SortByColumns(Filter(tablenameVar; CLASSE=DataCardValue3.Selected.Value); "COGNOM" ;Ascending)
 
Here, tablenameVar is the name of variable that will be used on all the screens.
 
Hope this Helps!
 
If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!
jvila
Level: Powered On

Re: Use a Variable as a Table name

Thanks!

 

The "taula_id" it comes from a previous screen via button with this code:

Navigate(sc_form; None; {curs_id: "3ESO"; taula_id: "TAULA_TUT_3ESO"})

 

So... where I put your code with the global variable?

 

Thanks!!!

 

 

Highlighted
jvila
Level: Powered On

Re: Use a Variable as a Table name

Perfect!

I just add your code at the end of my button code of the previous screen:

Navigate(sc_form; None; {curs_id: "3ESO"; taula_id: "TAULA_TUT_3ESO"}) && Set(tablenameVar; TAULA_TUT_3ESO)

So I will do the same with the other buttons!

 

Many, many Thanks!!

Super User
Super User

Re: Use a Variable as a Table name

Hey @jvila 

 

Glad that it worked!

 

Note: 

 

If you are passing this as a context variable, there is no need to create a global variable for it.
 
One other thing, regarding the navigation query, you have to pass the reference of data source rather than passing it as a string:
 
Navigate(sc_form; None; {curs_id: "3ESO"; taula_id: TAULA_TUT_3ESO})
 
You can modify your dropdown expression as:
 
SortByColumns(Filter(taula_id; CLASSE=DataCardValue3.Selected.Value); "COGNOM" ;Ascending)
 
Also, I want to highlight that the passed context variable won't work on other screens until it is passed as an arguments. If you dont pass to pass it everytime while navigation, I would suggest to use a global variable.
 
Hope this Helps!
 
If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!
jvila
Level: Powered On

Re: Use a Variable as a Table name

Fantastic! 

Thanks a lot!!!

The detail is to be a string or not :-)

Many thanks again!

jvila
Level: Powered On

Re: Use a Variable as a Table name

Dear @yashag2255 

 

With this code you showed me:

Navigate(sc_form; None; {curs_id: "3ESO"; taula_id: TAULA_TUT_3ESO})

It doesn't work. It shows the error icon

 

Even of this the DataSource of the form doesn't connect with the database (excel table). Even if I use tablenameVar with the previous code. When I test the App using "Alt" it runs... but when I preview it... anything... blank screen...

 

The idea is that the button pass the name of the table to the next screen where a form is waiting to be enabled with the name of the database. 

 

So... I'm fighting again...

Helpful resources

Announcements
firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

SecondImage

PowerApps Monthly Community Call

Next Wednesday, September 18th at 8am PDT

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

FirstImage

Power Platform World Tour

Coming to a city near you

thirdimage

PowerApps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

FourthImage

Join PowerApps User Group!!

Connect, share, and learn with your peers year-round

SecondImage

Power Platform Summit North America

Register by September 5 to save $200

Top Kudoed Authors
Users Online
Currently online: 263 members 4,314 guests
Please welcome our newest community members: