web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Use a Variable as a Ta...
Power Apps
Answered

Use a Variable as a Table name

(0) ShareShare
ReportReport
Posted on by 16

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!

Categories:
I have the same question (0)
  • Verified answer
    yashag2255 Profile Picture
    24,769 Super User 2024 Season 1 on at

    @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 Profile Picture
    16 on at

    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!!!

     

     

  • jvila Profile Picture
    16 on at

    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!!

  • yashag2255 Profile Picture
    24,769 Super User 2024 Season 1 on at

    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 Profile Picture
    16 on at

    Fantastic! 

    Thanks a lot!!!

    The detail is to be a string or not 🙂

    Many thanks again!

  • jvila Profile Picture
    16 on at

    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...

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 739 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 343 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard