cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
b00bski
Level: Powered On

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
RezaDorrani
Level 10

Re: Specific record from collection

Hi @b00bski 

 

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

3 REPLIES 3
RezaDorrani
Level 10

Re: Specific record from collection

Hi @b00bski 

 

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

v-siky-msft
Level 8

Re: Specific record from collection

Hi @b00bski ,

 

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

b00bski
Level: Powered On

Re: Specific record from collection

Thank you @RezaDorrani and @v-siky-msft 

 

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

Helpful resources

Announcements
firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

SecondImage

PowerApps Monthly Community Call

Tomorrow, September 18th at 8am PDT

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

FirstImage

Power Platform World Tour

Coming to a city near you

thirdimage

PowerApps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

FourthImage

Join PowerApps User Group!!

Connect, share, and learn with your peers year-round

SecondImage

Power Platform Summit North America

Register by September 5 to save $200

Top Kudoed Authors
Users Online
Currently online: 238 members 5,050 guests
Please welcome our newest community members: