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 Apps
Suggested Answer

AddColumns ...

(1) ShareShare
ReportReport
Posted on by 678
I currently have an items property that works, then I'm getting the values that I need within the context of the gallery in a separate text variable. This works and is fine in theory.
What I would prefer to do ... is add a column to the collection and then reference that in the gallery and perform whatever I want. I think the performance would be better that way.  Each row will append to a new column with a table of zero or more rows.

The data source is Dataverse.
So you can see below I'm trying to add a column called Rates to the parent table Contracts as I loop.
There's a relationship on the Contract column in the ContractRates table and ultimately I'm joining on the guid column which is Contract.


The way it works (below) now is to NOT add the Rates column using the AddColumns and instead inside the gallery do this...in a text label which works. What am I doing wrong in the code above. It could be a scope thing...the error message is that the specified column is not available in this context???
 
With(

    {

        _r: Filter(

            ContractRates,

            Contract.Contract = ThisItem.Contract

        )

    },

    With(

        {

            _max: Max(

                _r,

                Amount

            ),

            _min: Min(

                _r,

                Amount

            )

        },

        If(

            Value(_min) = Value(_max),

            Text(_min),

            $"{Text(_min)}-{Text(_max)}"

        )

    )

)

 
Categories:
I have the same question (0)
  • Suggested answer
    mmbr1606 Profile Picture
    14,605 Super User 2025 Season 2 on at
    hey
     
    can u try this modification;
    ClearCollect(
        colHotelRates,
        SortByColumns(
            AddColumns(
                Filter(Contracts, DateEnd > Today()),
                "Rates",
                Filter(
                    ContractRates,
                    Contract.Contract = ThisRecord.Contract
                ),
                "HotelBrand", dictHotel.hotelChain.dictHotelBrand.BrandName,
                "HotelCity", dictHotel.City,
                "HotelName", dictHotel.PropertyName,
                "SASRating", SASRating,
                "AverageRating",
                LookUp(
                    colSummarizedAvg,
                    HotelGUID = dictHotel.dictHotel,
                    AverageRating
                )
            ),
            "HotelCity", SortOrder.Ascending,
            "HotelName", SortOrder.Ascending
        )
    )
    
    if it worked please mark as verified answer
     
     
    cheers
  • sasrsc Profile Picture
    678 on at
    I tried that - and here's the response...

    The error is...



    I don't think I've ever tried to add a column that would reflect a table value i.e. Filtering. I've done plenty of LookUps.


  • timl Profile Picture
    36,393 Super User 2025 Season 2 on at
     
    This doesn't specifically answer your question about calling AddColumns.
     
    However, if the motivation for your change is to improve performance, you might want to consider one of these other approaches which would actually make a more significant improvement.
     
    The first is to define rollup columns in the Contracts table for the min and max Rates in Dataverse. This would work well if the rates don't change more than (say) once every 12 hours, which I guess could be true for hotel rates. By using this approach, the min and max will be calculated on the server which would be much quicker.
     
     
    If you prefer to do this entirely in Power Apps, the second approach you might consider is to call the Min and Max functions, rather than Filter.
     
    The way it works right now is for each Contract record, the call to Filter retrieves all associated rates for the Contract in order to determine only the min and max values. With Dataverse, the Min and Max functions are delegable, so you can directly retrieve the min and max values without retrieving all the in-between rates. 
     
     
    For this, the AddColumns part of your formula would look like this:
     
    AddColumns(
                Filter(Contracts, DateEnd > Today()),
                MinRate,
                Min(ThisRecord.Rates.Amount),
                MaxRate,
                Max(ThisRecord.Rates.Amount),
                FormattedValue,
                Min(ThisRecord.Rates.Amount) & " - " & Max(ThisRecord.Rates.Amount) 
    )
              
     
     

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

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 320 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard