Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Apps - Building Power Apps
Answered

Create a collection from a string

Like (0) ShareShare
ReportReport
Posted on 27 Feb 2023 11:48:19 by 12

Hello, 

I'm developing an app...and i have some issues that i can't fix it..

I have a string (from sharepoint list) and I have to transform this string in a collection...with the columns "Disciplina", "Premissas", "Fora do Escopo" e "Obrigações do Cliente"...sometimes this string will only have one register for each column, but sometimes it can be more...like this example below...

cathprado_0-1677498256814.png

my intention is using this collection in a gallery

cathprado_1-1677498444483.png

 

Thank you so much!!!

 

  • cathprado Profile Picture
    12 on 27 Feb 2023 at 18:26:36
    Re: Create a collection from a string

    It worked! Great!!! Thank you so much 🙂

  • Verified answer
    TheRobRush Profile Picture
    11,121 Super User 2025 Season 1 on 27 Feb 2023 at 16:47:48
    Re: Create a collection from a string

    Ok so to test this I put your snippet in a label, Label3, and am running the code from a buttons onselect

     

    You can use this to convert any string in that same format

     

    Button OnSelect is

    Clear(QueueCount);
    Clear(checkout);
    ForAll(Filter(Split(Label3.Text, "<br>"),!IsBlank(Result)) As checkDown, 
    If(Left(checkDown.Result, 11)="Disciplina:", Collect(QueueCount,{Value:1}));
    Collect(checkout, {Type: checkDown.Result, TypeCount: CountRows(QueueCount)})
    );
    
    ClearCollect(finalCollection, 
    ForAll(Sequence(CountRows(Distinct(checkout,TypeCount))) As recordCount,
     {Disciplina: Substitute(LookUp(checkout, TypeCount=recordCount.Value && Left(Type, 11)="Disciplina:").Type, "Disciplina:",""),
     Premissas: Substitute(LookUp(checkout, TypeCount=recordCount.Value && Left(Type, 10)="Premissas:").Type, "Premissas:",""),
     'Fora de Escopo': Substitute(LookUp(checkout, TypeCount=recordCount.Value && Left(Type, 15)="Fora de Escopo:").Type, "Fora de Escopo:",""),
     'Obrigações do Cliente': Substitute(LookUp(checkout, TypeCount=recordCount.Value && Left(Type, 22)="Obrigações do Cliente:").Type, "Obrigações do Cliente:","")}))

     

    Final collection looks like

    TheRobRush_0-1677516442317.png

     

  • cathprado Profile Picture
    12 on 27 Feb 2023 at 16:34:27
    Re: Create a collection from a string

    Hello, 

    The string in Sharepoint is like this:

    Disciplina: Mecânica<br>Premissas: yyyyyyyyyyyyyyyyy<br>Fora de Escopo: zzzzzzzzzzzzzzzzzz<br>Obrigações do Cliente: kkkkkkkkkkkkkkkk<br><br>Disciplina: Civil / Concreto<br>Premissas: huahuehaehae<br>Fora de Escopo: uaeuehauehuaeh<br>Obrigações do Cliente: shuasuhashuashu<br><br>

     

    I want a collection like this: 

    Disciplina | Premissas | Fora do Escopo | Obrigações do Cliente


    Sometimes it can be 1 record for the Gallery, sometimes 2, 3, 4...depends! In this case we have two...But i need to set the powerapps to show the records in a gallery no matter how it'll be...1 or 1000 hahah 🙂

  • TheRobRush Profile Picture
    11,121 Super User 2025 Season 1 on 27 Feb 2023 at 15:24:46
    Re: Create a collection from a string

    would this produce 2 records for your gallery, one for mecanica and one for civil/concreto that both have their own values for fora de escopo and premisas BUT share a value for obrigacoes do cliente?

     

    if so, when multiple records are present in a single string will they always have their own of those 2 and share the same obrigacoes do cliente (if they do soemtimes share the first two, will they always be listed seperately as above, or will it sometimes be dropped to the end as a signel listing like the obrigacoes? are there other pieces of data that will ever be present. or is it just these three?

  • cathprado Profile Picture
    12 on 27 Feb 2023 at 15:13:35
    Re: Create a collection from a string

    cathprado_0-1677510800303.png

     

  • TheRobRush Profile Picture
    11,121 Super User 2025 Season 1 on 27 Feb 2023 at 15:07:20
    Re: Create a collection from a string

    send an ecample of the splist displaying an item that only has one per column, and one that has 3 per columns, so we can differentiate between what happens to trigger both. what you have sent above is not enough information, it shows result of a multi entry one, but only the splist record of a single item with single entries on each column so it is unclear in your example why we would goto multiple items concatenated in the result

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!

Warren Belz – Community Spotlight

We are honored to recognize Warren Belz as our May 2025 Community…

Congratulations to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard > Power Apps - Building Power Apps

#1
MS.Ragavendar Profile Picture

MS.Ragavendar 32

#2
Rajkumar_M Profile Picture

Rajkumar_M 16 Super User 2025 Season 1

#3
mmbr1606 Profile Picture

mmbr1606 14 Super User 2025 Season 1

Overall leaderboard