cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anonymous
Not applicable

Specific record from collection

Hi,

 

I am trying to figure out how to display a record from a collection, only if there is data in the collection. 

 

I have a input box where the user writes Licance plates, several at a time.

The plate numbers are stored in a collection. - This all works fine.

 

The challange arrises when I retrive the plate numbers from the collection.
They will be shown in a Label, with strict system formating. The information in the label will, when finished, be sent out as an email. 

 

In order to keep to the system format, the plate number have to follow this format:

 

Plate 1, Plate 2 Plate 3

Plate 4, Plate 5, Plate 6

Plate 7, etc...

 

How do I get the plate numbers to show one by one and backspace after three entries?

I have tried Last(FirstN(collection, 1).column. This works if I know how many records there will be, but if there only is one or two records, the last plate shows up for each of the remaining Last(FirstN(collection, #) in the formula.

 

Any ideas?

1 ACCEPTED SOLUTION

Accepted Solutions
Dual Super User II
Dual Super User II

Hi @Anonymous 

 

One simple option would be to use a gallery to display the data in the collection and set the wrap cound for gallery to 3 so it will place 3 items in a row

 

Second option you would need an index (ID) for all your collection items

So lets say you have a collection like

ClearCollect(colPlates,{ID:1,Title:"Plate1"},{ID:2,Title:"Plate2"},{ID:3,Title:"Plate3"},{ID:4,Title:"Plate4"},{ID:5,Title:"Plate5"},{ID:6,Title:"Plate6"},{ID:7,Title:"Plate7"})

 

 

Then all you need to do for label is use

Concat(colPlates,If(Mod(ID,3)=0, Title & Char(13), Title &","))

 

Regards,

Reza Dorrani

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

View solution in original post

4 REPLIES 4
Dual Super User II
Dual Super User II

Hi @Anonymous 

 

One simple option would be to use a gallery to display the data in the collection and set the wrap cound for gallery to 3 so it will place 3 items in a row

 

Second option you would need an index (ID) for all your collection items

So lets say you have a collection like

ClearCollect(colPlates,{ID:1,Title:"Plate1"},{ID:2,Title:"Plate2"},{ID:3,Title:"Plate3"},{ID:4,Title:"Plate4"},{ID:5,Title:"Plate5"},{ID:6,Title:"Plate6"},{ID:7,Title:"Plate7"})

 

 

Then all you need to do for label is use

Concat(colPlates,If(Mod(ID,3)=0, Title & Char(13), Title &","))

 

Regards,

Reza Dorrani

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

View solution in original post

Community Support
Community Support

Hi @Anonymous ,

 

I quite agree with @RezaDorrani ’s second option.

I have made a test , and some additions are made because the I found it ends with a comma sometimes.

 

First, the ID Column is needed to be indexed.

Second, Use concat function to format the label text.

Third, determine if there is a comma at the end and replace it with blank if is.

Please refer to following formula:

If(Mod(Last(Collection).ID,3)=0,Concat(Collection,If(Mod(ID,3)=0,PlateNo&Char(13),PlateNo&",")),Substitute(Concat(collection,If(Mod(ID,3)=0, PlateNo&Char(13),PlateNo&",")),",","",(RoundDown(Last(collection).ID/3,0)*2+Mod(Last(collection).ID,3))))

Capture2.PNG

 

Best regards,

Sik

Anonymous
Not applicable

Thank you @RezaDorrani and @v-siky-msft 

 

I got it working with: Concat(colPlates,If(Mod(ID,3)=0, Title & Char(13), Title &",")) 

Anonymous
Not applicable

Hi @RezaDorrani ,

 

Thanks for your help first time around.

 

I have encountered another issue.

 

When I use your setup, it all works fine until the user starts deleting items before hitting send.

 

Current format of:

Plate1, Plate2, Plate3

Plate4, Plate 5, Plate6

Plate 7, Plate 8, and so on…

 

If ID #3 is removed due to typo, it is formatted like this:

Plate1, Plate2, Plate4, Plate5, Plate 6

Plate 7, Plate8, and so on…

 

Any suggestion on how to either Patch ID or getting this to work?

 

Thank you!

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

News & Announcements

Community Blog

Stay up tp date on the latest blogs and activities in the community News & Announcements.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Community Highlights

Community Highlights

Check out the Power Platform Community Highlights

Top Solution Authors
Top Kudoed Authors
Users online (7,898)