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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / The second argument to...
Power Apps
Unanswered

The second argument to the "Index" function error when filtering collection results.

(0) ShareShare
ReportReport
Posted on by 2
Hi All,
 
I wonder if anyone can help. I am losing the will to live with this one. So I have a "|" delimited string from an API that I am Splitting into a Collection and using a sequence to ensure all the values go into the right columns. This works fine and I can do a "CountRows" function and I can obtain the info I want..
 
With({items:Split(RecLMIGeneralChannelOutput.opgeneralchanneldata,"|")},
    ClearCollect(colActiveSessions2,ForAll(Sequence(CountRows(items),1,19),
        {
            SessionID: Index(items,Value + 1).Value,
            SessionStatus: Index(items,Value + 2).Value,
            ChannelID: Index(items, Value + 3).Value,
            Channel: Index(items,Value + 4).Value,
            TechnicianID: Index(items,Value + 5).Value,
            Technician: Index(items,Value + 6).Value,
            StartTime: Index(items,Value + 7).Value,
            WaitingTime: Index(items,Value + 8).Value,
            CustomField0: Index(items,Value + 9).Value,
            CustomField1: Index(items,Value + 10).Value,
            CustomField2: Index(items,Value + 11).Value,
            CustomField3: Index(items,Value + 12).Value,
            CustomField4: Index(items,Value + 13).Value,
            CustomField5: Index(items,Value + 14).Value,
            Language: Index(items,Value + 15).Value,
            TransferredTo: Index(items,Value + 16).Value,
            TransferredComment: Index(items,Value + 17).Value,
            IsLeadTechnician: Index(items,Value + 18).Value,
            HandingOff: Index(items,Value + 19).Value
        }
    )
));
 
If(!IsError(CountRows(colActiveSessions2)/19), Int(CountRows(colActiveSessions2)/19), 0)
 
The above works fine, but then if I try to filter the results I get an error to obtain another value I get an Index error...
 
So this is the line..
 
If(!IsError(CountRows(Filter(colActiveSessions2,SessionStatus = "Waiting"))/19), Int(CountRows(Filter(colActiveSessions2, SessionStatus = "Waiting"))/19), 0)
 
And this is the error..
 
Hope someone can help!!!  
Categories:
  • mmbr1606 Profile Picture
    14,629 Super User 2026 Season 1 on at
    hey
     
     
     
    can u try this modification:
    With(
        {items: Split(RecLMIGeneralChannelOutput.opgeneralchanneldata, "|")},
        ClearCollect(
            colActiveSessions2,
            ForAll(
                Sequence(CountRows(items), 1, 19),
                {
                    SessionID: Index(items, Value + 1).Value,
                    SessionStatus: Index(items, Value + 2).Value,
                    ChannelID: Index(items, Value + 3).Value,
                    Channel: Index(items, Value + 4).Value,
                    TechnicianID: Index(items, Value + 5).Value,
                    Technician: Index(items, Value + 6).Value,
                    StartTime: Index(items, Value + 7).Value,
                    WaitingTime: Index(items, Value + 8).Value,
                    CustomField0: Index(items, Value + 9).Value,
                    CustomField1: Index(items, Value + 10).Value,
                    CustomField2: Index(items, Value + 11).Value,
                    CustomField3: Index(items, Value + 12).Value,
                    CustomField4: Index(items, Value + 13).Value,
                    CustomField5: Index(items, Value + 14).Value,
                    Language: Index(items, Value + 15).Value,
                    TransferredTo: Index(items, Value + 16).Value,
                    TransferredComment: Index(items, Value + 17).Value,
                    IsLeadTechnician: Index(items, Value + 18).Value,
                    HandingOff: Index(items, Value + 19).Value
                }
            )
        )
    );
    
    IfError(
        Int(CountRows(Filter(colActiveSessions2, SessionStatus = "Waiting")) / 19),
        0
    )
    
    if it worked please mark as verified answer,
     
     
    cheers
  • JL-06111550-0 Profile Picture
    2 on at
    Sorry mmrbr1606 that didn't work :(
     
    The filter seems to work ok, but it's when it comes to do the "CountRows" function after the filter, that when it gets the error. When I do a CountRows just on the collection without the filter it works fine so the filter must be affecting the indexing somehow?
     

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 345 Super User 2026 Season 2

#2
M Bilal Khan Profile Picture

M Bilal Khan 312

#3
Mohsin Ali Profile Picture

Mohsin Ali 252

Last 30 days Overall leaderboard