cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Helper I
Helper I

How to split column value on delimiter and generate row numbers correctly in collection

I'm able to generate the collection with split column values, but struggling to generate row numbers correctly for the split values

 

ClearCollect(Collection1,ShowColumns(Filter('SPList',ID=1),"column1"));

Set(stored1, Concat(Collection1, column1));

Set(intRow,1);
ClearCollect(Collection2,ShowColumns(ForAll(Split(stored1,";"),{Column1: First(Split(Result,";").Result).Result,RowID:intRow}),"Column1","RowID"));Set(intRow, intRow+1);

 

 

 Getting:

Column1RowID
Value11
Value21
Value31
Value41
Value51

 

Looking for:

Column1 RowID
Value11
Value22
Value33
Value44
Value55
2 ACCEPTED SOLUTIONS

Accepted Solutions
Highlighted
Power Apps
Power Apps

Re: How to split column value on delimiter and generate row numbers correctly in collection

If you want to create a new collection with the column 'column1' from Collection1, and an index of the rows, you can use an expression like this one:

ClearCollect(
    Collection2,
    AddColumns(
        RenameColumns(Sequence(CountRows(Collection1)), "Value", "RowID"),
        "Column1", Last(FirstN(Collection1, RowID)).column1))

The idea is to first create the indices (using the Sequence function) then add the column from the original collection to it by accessing the object by index (using the Last(FirstN(collection, index)) construct).

Hope this helps! 

View solution in original post

Highlighted
Super User III
Super User III

Re: How to split column value on delimiter and generate row numbers correctly in collection

@DBJ 

 

I am not following your first few lines of the formula.  You appear to be filtering to 1 specific record and returning just the "column1".  This would mean that your stored1 variable would have the concat of 1 row...so not really needed since it is one row.

 

If you are just working with one row and a column that has delimited items in it, then consider this following formula:

Clear(colResults);
ForAll(
    Split(LookUp(SPList, ID=1, column1), ";"),    
    Collect(colResults, {Column1: Result, RowID: CountRows(colResults)+1})
)

 

If you are doing this over several rows from your data source, then consider this formula:

Clear(colResults);
ForAll(
    Split(
        Concat(
             Filter(SPList, 'lookupCriteria'), 
             column1 & ";"
        ), 
        ";"
    ),    
    Collect(colResults, {Column1: Result, RowID: CountRows(colResults)+1})
)

 

I hope this is helpful for you.

 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.

View solution in original post

4 REPLIES 4
Highlighted
Power Apps
Power Apps

Re: How to split column value on delimiter and generate row numbers correctly in collection

If you want to create a new collection with the column 'column1' from Collection1, and an index of the rows, you can use an expression like this one:

ClearCollect(
    Collection2,
    AddColumns(
        RenameColumns(Sequence(CountRows(Collection1)), "Value", "RowID"),
        "Column1", Last(FirstN(Collection1, RowID)).column1))

The idea is to first create the indices (using the Sequence function) then add the column from the original collection to it by accessing the object by index (using the Last(FirstN(collection, index)) construct).

Hope this helps! 

View solution in original post

Highlighted
Super User III
Super User III

Re: How to split column value on delimiter and generate row numbers correctly in collection

@DBJ 

 

I am not following your first few lines of the formula.  You appear to be filtering to 1 specific record and returning just the "column1".  This would mean that your stored1 variable would have the concat of 1 row...so not really needed since it is one row.

 

If you are just working with one row and a column that has delimited items in it, then consider this following formula:

Clear(colResults);
ForAll(
    Split(LookUp(SPList, ID=1, column1), ";"),    
    Collect(colResults, {Column1: Result, RowID: CountRows(colResults)+1})
)

 

If you are doing this over several rows from your data source, then consider this formula:

Clear(colResults);
ForAll(
    Split(
        Concat(
             Filter(SPList, 'lookupCriteria'), 
             column1 & ";"
        ), 
        ";"
    ),    
    Collect(colResults, {Column1: Result, RowID: CountRows(colResults)+1})
)

 

I hope this is helpful for you.

 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.

View solution in original post

Highlighted
Helper I
Helper I

Re: How to split column value on delimiter and generate row numbers correctly in collection

@CarlosFigueira ,

 

I'm trying to split the values from column1, with your example the collection still displays a delimited value. @RandyHayes  answered my question with his first example. Thanks for taking the time to look at it though and showing me the sequence function, I'll probably use it at some point.

Highlighted
Super User III
Super User III

Re: How to split column value on delimiter and generate row numbers correctly in collection

@DBJ 

Actually the approach that @CarlosFigueira could work as well, it is just another trick to get sequential numbers into a table.

 

Glad it is working for you.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

Power Platform ISV Studio

Power Platform ISV Studio

ISV Studio is designed to become the go-to Power Platform destination for ISV’s to monitor & manage published applications.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Tech Marathon

Maratón de Soluciones de Negocio Microsoft

Una semana de contenido con +100 sesiones educativas, consultorios, +10 workshops Premium, Hackaton, EXPO, Networking Hall y mucho más!

Top Solution Authors
Top Kudoed Authors
Users online (5,510)