Skip to main content

Notifications

Power Apps - Building Power Apps
Answered

Display #order of selected item in a gallery

(0) ShareShare
ReportReport
Posted on by 226
Hello! This feels as though it should be fairly simple, but I'm trying to work around it.
 
I have a gallery galDivInnvUtstyr which lets the user tick of for any item that is desired, and a text-input for the amount of that item:
 
 
The problem occurs when I'm trying to retreive the data that the user have previously saved in SharePoint.
The data that is passed to SharePoint is a text string using the code:
 
Diverse_x0020_innvendig_x0020_ut: {Value:
Concat(
Filter(
galDivInnvUtstyr.AllItems,
chDivInnvUtstyr.Value = true
),
txtDivInnvUtstyrAmount.Text&" x "&Value, " + "
      
)}.Value
 
The string looks like:
5 x Medisinkoffert på vegg + 2 x Papirhåndkle-holder (stor type) + 3 x Søppelkurv 12L + 2 x Såpedispenser (standard type)
 
I usually store this into a collection which i call colListe.
 
And I can split the string using the following:
 
Last(FirstN(Split(First(colListe).'Diverse innvendig utstyr'.Value, " + "),1)).Value
 
Which becomes:
5 x Medisinkoffert på vegg
 
I just can't find a way to dynamically alter the order of the number that corresponds to the order of the chosen item.
 
 
Now, displaying whether the user has chosen the item or not is fairly simple with the code in the checkbox:
 
If(
    chDivInnvUtstyr.Text in First(colListe).'Diverse innvendig utstyr'.Value,
    true
)
 
But displaying the amount of items the users has put in becomes hard.
 
 
Any tips?
 
Thanks in advance!
John
 
 
 
  • Johnolnes Profile Picture
    Johnolnes 226 on at
    Display #order of selected item in a gallery
    Worked like a charm!
     
    Thanks @VeGETzX 
  • Verified answer
    VeGETzX Profile Picture
    VeGETzX 338 on at
    Display #order of selected item in a gallery
    Hi,
     
    As per my try,

    I think the easiest way is to transform "5 x Medisinkoffert på vegg + 2 x Papirhåndkle-holder (stor type) + 3 x Søppelkurv 12L + 2 x Såpedispenser (standard type)" into collection that have two column to separate the item name and its quantity, so you can use formula just like
     
    txtQuantity.Text in colTest.Qty
    Find some event to create the collection may be screen's OnVisible or button OnSelect
     
    Replace TextInput1.Text with First(colListe).'Diverse innvendig utstyr'.Value
     
    ClearCollect(
        colTest,
        ShowColumns(
            AddColumns(
                AddColumns(
                    Split(
                        TextInput1.Text,
                        "+"
                    ),
                    TrimmedText,
                    Trim(Value)
                ),
                Qty,
                Trim(
                    First(
                        Split(
                            TrimmedText,
                            "x"
                        )
                    ).Value
                ),
                Name,
                With(
                    {
                        splitteds: Split(
                            TrimmedText,
                            "x"
                        )
                    },
                    Concat(
                        LastN(
                            splitteds,
                            CountRows(splitteds) - 1
                        ),
                        Value,
                        ""
                    )
                )
            ),
            Name,
            Qty
        )
    )
     
     
     

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

November 2024 Newsletter…

November 2024 Community Newsletter…

Community Update Oct 28…

Power Platform Community Update…

Tuesday Tip #9 Get Recognized…

Welcome to a brand new series, Tuesday Tips…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 143,867

#2
RandyHayes Profile Picture

RandyHayes 76,308

#3
Pstork1 Profile Picture

Pstork1 64,161

Leaderboard