Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Apps - Building Power Apps
Answered

Adding Columns Changes the data in my Gallery

(0) ShareShare
ReportReport
Posted on by 130

Hi,

I've been learning Power Apps and have been having trouble searching the data in my gallery since none of the columns in my SP list are single text columns, but rather lookup or choice columns. I've looked up solutions to this which include the "AddColumns" function, which I tried and after I'm finished writing the function below, it changes the way I've configured the data in my gallery and doesn't allow me to add or remove fields.

 

Here is a screen shot of my function

LS579_0-1660663799815.png

 

I am essentially connecting to a SharePoint calendar list.

 

Thanks!

  • LS579 Profile Picture
    130 on at
    Re: Adding Columns Changes the data in my Gallery

    @RandyHayes 

    It gives me an error saying that it expects text. 😓

     

    LS579_0-1660741866110.png

     

  • RandyHayes Profile Picture
    76,287 Super User 2024 Season 1 on at
    Re: Adding Columns Changes the data in my Gallery

    @LS579 

    Yes, you can add any number of columns you want to be searchable.

    Search(
     AddColumns('ATCNA Cincinnati On Call Calendar',
     "_PrimaryOnCall", 'Primary On Call'.Value,
     "_LookupColumn", LookUpColumNameHere.Value
     ),
     txtSearch.Text,
     "_PrimaryOnCall", "_LookupColumn"
    )

     

    Adding the columns will not impact what you already have.  All of the original columns will be in your items table, so whatever you have in the gallery will not change.

  • LS579 Profile Picture
    130 on at
    Re: Adding Columns Changes the data in my Gallery

    @RandyHayes 

    ... and how do you keep the function from changing my data in my gallery? That was the main issue I was having with trying to use the search function for the lookup column. My gallery fields would change from what I had it set as.

  • LS579 Profile Picture
    130 on at
    Re: Adding Columns Changes the data in my Gallery

    @RandyHayes 

    Thank you. That worked for another column I wanted to search for as it was a choice column, however, the column in my example is a look up column. I read how to write the function for that in another post, but can you combine the two in "items" and what would that look like? The function didn't look much different than what you had above, but somehow it reacts differently. Do you have any insight on that subject?

  • Verified answer
    RandyHayes Profile Picture
    76,287 Super User 2024 Season 1 on at
    Re: Adding Columns Changes the data in my Gallery

    @LS579 

    If that is a Choice column, then change your Formula to the following:

    Search(
     AddColumns('ATCNA Cincinnati On Call Calendar',
     "_PrimaryOnCall", 'Primary On Call'.Value
     ),
     txtSearch.Text,
     "_PrimaryOnCall"
    )

    Two things...

    1) You will need to single quote your actual column as seen above and reference the Value column of that Choice record to get the value for your new column.

    2) Avoid using the same name for your new column that you already have in your datasource.  This is confusing and will usually lead to an error.  The above prepends it with an underscore.

     

    I hope this is helpful for you.

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

Understanding Microsoft Agents - Introductory Session

Confused about how agents work across the Microsoft ecosystem? Register today!

Markus Franz – Community Spotlight

We are honored to recognize Markus Franz as our April 2025 Community…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,702 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 66,015 Most Valuable Professional

Leaderboard