cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
mmchx
Helper IV
Helper IV

'Index' function run time error

Hi, all I just what to show the version history app which uses the SharePoint list as Data Source.

So, I use the flow and pass the values into the power app which works fine. but when I collect those values into the collection and show them in the Gallery. I face a run time error like this which I'm not sure is about the way I collect those values into the collection.

This is my code that use split the values from the flow and collects them into a collection

The collection that I use as the data source in Gallery is "colHistory"

Set(varHistory,GetHistory.Run(Gallery1_1.Selected.Id).history);//set varHistory = history's selected item
//spilt varHistory with "|" & collect to colHistoryTemp
ClearCollect(
    colHistoryTemp,
    Split(
        varHistory,
        "|"
    )
);
ForAll(
    colHistoryTemp,
    Collect(
        colHistory,
        {
            Date: DateTimeValue( First(Split( Result,";").Result).Result,"nl-NL"),
            Version: Last(FirstN(Split(Result,";").Result,2).Result).Result,
            Editor:  Index(Split(Result,";").Result,3).Result,
            R01: Index(Split(Result,";").Result,4).Result,
            R02: Index(Split(Result,";").Result,5).Result,
            R03: Index(Split(Result,";").Result,6).Result,
            P01: Index(Split(Result,";").Result,7).Result,
            P02: Index(Split(Result,";").Result,8).Result,
            P03: Index(Split(Result,";").Result,9).Result,
            P04: Index(Split(Result,";").Result,10).Result,
            P05: Index(Split(Result,";").Result,11).Result,
            P06: Index(Split(Result,";").Result,12).Result,
            P07: Index(Split(Result,";").Result,13).Result,
            P08: Index(Split(Result,";").Result,14).Result,
            P09: Index(Split(Result,";").Result,15).Result,
            P10: Index(Split(Result,";").Result,16).Result,
            P11: Index(Split(Result,";").Result,17).Result,
            P12: Last(Split(Result,";").Result).Result
        }
    )
);
Sort( colHistory, Date,Descending);
//Navigate(LogScreen);

 

mmchx_1-1663344454346.png

but I already change the data limit row to 2000, it doesn't work.

Could you please guide me on this?

1 ACCEPTED SOLUTION

Accepted Solutions
RandyHayes
Super User
Super User

@mmchx 

Oops...yet another typo.  Forgot the opening curly bracket!!

I edited the post with the formulas...they should be fixed for that problem.  Use those.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

View solution in original post

5 REPLIES 5
RandyHayes
Super User
Super User

@mmchx 

Record limit is not related to this.  It has to do with the Index function.

First, your ForAll is used backward, so correct that with the following formula:

 

 

With({_history: GetHistory.Run(Gallery1_1.Selected.Id).history},
    ClearCollect(colHistory, 
        Sort(
            ForAll(Split(_history, "|"),
                With({_s: Split(Result, ";")},
                    {
                    Date: DateTimeValue( Index(_s, 1).Result, "nl-NL"),
                    Version: Index(_s, 2).Result,
                    Editor:  Index(_s, 3).Result,
                    R01: Index(_s, 4).Result,
                    R02: Index(_s, 5).Result,
                    R03: Index(_s, 6).Result,
                    P01: Index(_s, 7).Result,
                    P02: Index(_s, 8).Result,
                    P03: Index(_s,9).Result,
                    P04: Index(_s, 10).Result,
                    P05: Index(_s, 11).Result,
                    P06: Index(_s, 12).Result,
                    P07: Index(_s, 13).Result,
                    P08: Index(_s, 14).Result,
                    P09: Index(_s, 15).Result,
                    vP10: Index(_s, 16).Result,
                    P11: Index(_s, 17).Result,
                    P12: Index(_s, 18).Result
                }
            ),
            Date,Descending
        )        
    )
)

 

 

 

Next...it is imperative that your split item have 18 results to it.  If any will NOT have 18, then you will encounter run time issues.

 

If you want to reject any records that do not have 18 splits, then that is one way around it...

Formula would be:

 

 

With({_history: GetHistory.Run(Gallery1_1.Selected.Id).history},
    ClearCollect(colHistory, 
        Sort(
          Filter(
            ForAll(Split(_history, "|"),
                With({_s: Split(Result, ";")},
                    If(CountRows(_s)=18, 
                        {
                        Date: DateTimeValue( Index(_s, 1).Result, "nl-NL"),
                        Version: Index(_s, 2).Result,
                        Editor:  Index(_s, 3).Result,
                        R01: Index(_s, 4).Result,
                        R02: Index(_s, 5).Result,
                        R03: Index(_s, 6).Result,
                        P01: Index(_s, 7).Result,
                        P02: Index(_s, 8).Result,
                        P03: Index(_s,9).Result,
                        P04: Index(_s, 10).Result,
                        P05: Index(_s, 11).Result,
                        P06: Index(_s, 12).Result,
                        P07: Index(_s, 13).Result,
                        P08: Index(_s, 14).Result,
                        P09: Index(_s, 15).Result,
                        vP10: Index(_s, 16).Result,
                        P11: Index(_s, 17).Result,
                        P12: Index(_s, 18).Result
                    }
                )
            ),
            !IsBlank(Date)
          ),
          Date,Descending
        )        
    )
)

 

 

 

Otherwise, you will have to apply other logic for scenarios where there are not 18 splits.

 

I hope this is helpful for you.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

 

With({varLog: GetHistory.Run(Gallery1_1.Selected.Id).history)},
    ClearCollect(colHistory, 
        Sort(
          Filter(
            ForAll(Split(varLog, "|"),
                With({_s: Split(Result, ";")},
                    If(CountRows(_s)=18, 
                        {
                        Date: DateTimeValue( Index(_s, 1).Result, "nl-NL"),
                        Version: Index(_s, 2).Result,
                        Editor:  Index(_s, 3).Result,
                        R01: Index(_s, 4).Result,
                        R02: Index(_s, 5).Result,
                        R03: Index(_s, 6).Result,
                        P01: Index(_s, 7).Result,
                        P02: Index(_s, 8).Result,
                        P03: Index(_s,9).Result,
                        P04: Index(_s, 10).Result,
                        P05: Index(_s, 11).Result,
                        P06: Index(_s, 12).Result,
                        P07: Index(_s, 13).Result,
                        P08: Index(_s, 14).Result,
                        P09: Index(_s, 15).Result,
                        vP10: Index(_s, 16).Result,
                        P11: Index(_s, 17).Result,
                        P12: Index(_s, 18).Result
                    }
                )
            ),
            !IsBlank(Date)
          ),
          Date,Descending
        )        
    )
)

 

Just try your code, but there has an error in the first line

the error said the formula isn't correct, sorry for my poor coding.😥

 

With({varLog: GetHistory.Run(Gallery1_1.Selected.Id).history)},

 

 
RandyHayes
Super User
Super User

@mmchx 

Sorry...we type these things all by hand.  There is no error checking!!  So sometimes there are typos.

 

In this case, I neglected to remove the last closing paren.   I will correct in the prior post.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

mmchx_1-1663349555510.png

still has an error, just change the variable, since "_history" is invalid here. 🤔 very weird that it suppose to work because it's a valid name.

RandyHayes
Super User
Super User

@mmchx 

Oops...yet another typo.  Forgot the opening curly bracket!!

I edited the post with the formulas...they should be fixed for that problem.  Use those.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

Helpful resources

Announcements
Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Difinity Conference 2022

Difinity Conference 2022

Register today for two amazing days of learning, featuring intensive learning sessions across multiple tracks, led by engaging and dynamic experts.

European SharePoint Conference

European SharePoint Conference

The European SharePoint Conference returns live and in-person November 28-December 1 with 4 Microsoft Keynotes, 9 Tutorials, and 120 Sessions.

Power Apps Ideas

Changes to Ideas Coming

We are excited to announce a new way to share your ideas for Power Apps!

Top Solution Authors
Top Kudoed Authors
Users online (2,068)