cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Tapesh
Post Prodigy
Post Prodigy

How to use Sequence and Patch /update to show in gallery?

Hi Experts, 

I m trying to create a model where I want the number to be in an incremental order based on the rows present in the Gallery.
For example: 
If I have a Gallery1, which has textinput = customerAppid, I would like to change the customerAppid to 0 and then 1 and 2 and 3 so on until the last row in the Gallery. 

for the solution, I have tried using the Sequence formula and the Patch using ForALL but the result is it only patches the first row from the Sequence in the gallery and the rest of them are the same no change.  

I do not know If Im correct or missing any bits of the formula. It would be a really great help if any suggestion provided by experts like you. 

Please have a look at the formula below:

OnSelect of Button: 

 

ForAll(RenameColumns( ExportData, "Customer_AppId", "ECustomer_AppId"),  Patch(ExportData, LookUp(ExportData, Customer_AppId  = ECustomer_AppId), {Customer_AppId: Value(RowNumber.Text)}))

 

In Sequence Gallery

Item: 

 

Sequence(Value(RowNumbLabel.Text), 0) As SeqRowNumber

 

In exportDataGal, 

 

Text Input = ThisItem.Customer_AppId

 

Please find the image below as a reference.
Note: The order on the left with box border is all 0 and not as same as it's in the right-hand side gallery such as 0,1 2, 3, 4.


Tapesh_0-1613135716678.png

 


Any help or suggestion would be really appreciated. 

Thanks in advance. 



1 ACCEPTED SOLUTION

Accepted Solutions

Hi @Tapesh ,

 

One approach could be like this. For Example I created a Data Table with a collection as data source. You can do the same for your gallery.

Added two buttons 1 to Create a new record one to clear the collection. Looks like this.

MasterB_0-1613137408771.png

As long as you do not intend to delete single rows from the collection the logic is simple. Since you start with zero. The next increment is the same as the amount of rows you already have in you Collection
So on the submit button I added this function as OnSelect:

 

Set(
    varSequence,
    CountRows(coll_GalleryData)
);
Collect(
    coll_GalleryData,
    {
        unique_id: varSequence,
        data: "DataBlock_" & varSequence
    }
)

 

Count the rows of the collection and put them into a variable every time you click the button. Then use this variable eg. as your Unique Identifier for the row or concatenate into a text or any other thing you might need it.

 

The other button is just:

 

Clear(coll_GalleryData)

 

 

Is this the way you intended it to work?

Give it a try in a simple setup like I bolted together as example here, before you integrate it into you app

Code on!

 

Best

Jan aka MasterB

View solution in original post

6 REPLIES 6
MasterB
Advocate II
Advocate II

 Tapesh,

 

do you need this sequence as kind of unique ID in the gallery? Is it necessary to be an Integer that is incremented?

2 things come to my mind.

 

Let the underlying datasource take care of the sequence. eg. an identity Column in SQL. Not beeing a sharepoint guy, but I think sharepoint automaticaly creates a unique ID as well.

 

If it must be unique but no integer... Maybe take a look to the GUID function. It should work with for all...

 

Code on!

Jan aka MasterB

Hi @MasterB ,


Thanks for your quick response sir, and yeah the number must start with 0 and should Increase in incremental order only. As I just want to give number to the gallery items and then take the same number and send to flow as collection. 

any suggestion or second thought on your mind sir?

Hi @Tapesh ,

 

One approach could be like this. For Example I created a Data Table with a collection as data source. You can do the same for your gallery.

Added two buttons 1 to Create a new record one to clear the collection. Looks like this.

MasterB_0-1613137408771.png

As long as you do not intend to delete single rows from the collection the logic is simple. Since you start with zero. The next increment is the same as the amount of rows you already have in you Collection
So on the submit button I added this function as OnSelect:

 

Set(
    varSequence,
    CountRows(coll_GalleryData)
);
Collect(
    coll_GalleryData,
    {
        unique_id: varSequence,
        data: "DataBlock_" & varSequence
    }
)

 

Count the rows of the collection and put them into a variable every time you click the button. Then use this variable eg. as your Unique Identifier for the row or concatenate into a text or any other thing you might need it.

 

The other button is just:

 

Clear(coll_GalleryData)

 

 

Is this the way you intended it to work?

Give it a try in a simple setup like I bolted together as example here, before you integrate it into you app

Code on!

 

Best

Jan aka MasterB

View solution in original post

If you intend to delete single rows from the connection. you can use Max Function to evaluate the highest value from you ID column and increment it then. Be careful for the first entry so. Maybe you have to use an If to get you started with zero.

 

Then it is just this to evaluate the next Number in the Sequence:

Set(
    varSequence,
    Max(coll_GalleryData,unique_id)+1
);

 

Code on!!!

Hey @MasterB 

Brilliant I have to say this. It's a pretty amazing solution to what I was looking for, just had to twerk around a bit to get on the point but finally, I  got what I was looking for. 

Thank you so much for the help and quick response sir. 


@Tapesh glad it helped you!

Code on!!!

Best

Jan aka MasterB

Helpful resources

Announcements
PA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

PowerPlatform 768x460.png

Microsoft Learn

Check out our new Discover Your Career Path blog post series and get all the details.

Users online (1,096)