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 / Table and collection p...
Power Apps
Answered

Table and collection problem

(0) ShareShare
ReportReport
Posted on by 14
 

Hello everyone,

I have a button that writes data into a table, and it works perfectly for a specific table name. However, I need to make it dynamic so that it updates a table based on a user’s input (a text field for the username).

I tried defining the table for each user, and while the LookUp function seems to be working fine, I’m getting an error with the UpdateIf function. The error says that the first argument of UpdateIf must be a collection.

Could anyone help me figure out how to make the button update the correct table based on the username input? I’d appreciate any guidance!

Thanks in advance!

 

Set(selectedTable; If(
    Input_User.Text = "bperez"; bperez;
    Input_User.Text = "crovera"; crovera;
    Input_User.Text = "dsalva"; dsalva;
    bperez
));;

Set(foundRow; LookUp(selectedTable; DateValue(Text(Date)) = DateValue(Text(formattedDate))));;

If(
    IsBlank(foundRow.Proposal);
    UpdateIf(
        selectedTable;
        DateValue(Text(Date)) = DateValue(Text(formattedDate));
        {
            Location: Text(Location_Input.Selected.Value);
            Activity: Input_Activity.Text
        }
    );
    Set(PopupVisible; true)
);;
 
Categories:
I have the same question (0)
  • Verified answer
    WarrenBelz Profile Picture
    153,136 Most Valuable Professional on at
    Unfortunately you cannot refer to data sources dynamically - the string "bperez" is not the data source bperez. You would need to do this the "long" way.
    Switch(
        Input_User.Text;
       "bperez"; 
       If(
          IsBlank(
             LookUp(
                bperez; 
                DateValue(Text(Date)) = DateValue(Text(formattedDate))
             ).Proposal
          );
          UpdateIf(
             bperez;
             DateValue(Text(Date)) = DateValue(Text(formattedDate));
             {
                Location: Text(Location_Input.Selected.Value);
                Activity: Input_Activity.Text
             }
          )
       );
       "crovera";
       If(
          IsBlank(
             LookUp(
                crovera; 
                DateValue(Text(Date)) = DateValue(Text(formattedDate))
             ).Proposal
          );
          UpdateIf(
             crovera;
             DateValue(Text(Date)) = DateValue(Text(formattedDate));
             {
                Location: Text(Location_Input.Selected.Value);
                Activity: Input_Activity.Text
             }
          )
       );
       "dsalva";
        If(
          IsBlank(
             LookUp(
                dsalva; 
                DateValue(Text(Date)) = DateValue(Text(formattedDate))
             ).Proposal
          );
          UpdateIf(
             dsalva;
             DateValue(Text(Date)) = DateValue(Text(formattedDate));
             {
                Location: Text(Location_Input.Selected.Value);
                Activity: Input_Activity.Text
             }
          )
       )
    );;
    Set(PopupVisible; true)
     
    Please click Does this answer your question if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it a Like.
    MVP (Business Applications)    Visit my blog Practical Power Apps    LinkedIn    Buy me a coffee

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 740 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 342 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard