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

Convert Collection to record type so that it can be used in gallery

Hi All,

 

i am currently making a collection through clear collect. Below is the code. However, when i insert the collection into the gallery and when i try and select the column from collection, it throws an error saying required type is record.

How do i solve this?

Collect(
    projectnames,
    {
        projectname: Distinct(
            'F.P Details of Module',
            'Project Name'
        ),
        adjustedfp: Distinct(
            'F.P Details of Module',
            'Adjusted F.P'
        ),
        unadjustedfp: Distinct(
            'F.P Details of Module',
            'Unadjusted F.P'
        ),
        finalfp: Distinct(
            'F.P Details of Module',
            'Final F.P'
        ),
        unqiueid: Distinct(
            'F.P Details of Module',
            'Unique ID'
        )
    }
)
1 ACCEPTED SOLUTION

Accepted Solutions

Hi@Jayant2

Based on the issue that you mentioned, do you want to create a collection based on the distinct project name?

Could you please share a bit more about the 'F.P Details of Module'?

From your description, I think you want to display the distinct result based on the project name, every section in the Gallery will display a distinct project name and each Label within will display the corresponding distinct other column values.

If my understanding is correct, I think you should directly use the GroupBy () rather than the Collect().

In my scenario, all the column type are Text type.

Set the Items property of the Gallery as below:

GroupBy('F.P Details of Module',"ProjectName","NameG")

Set Text property of the Label within as below:

ThisItem.ProjectName // for the distinct ProjectName 
Concat(Distinct(ThisItem.NameG.'Adjusted F.P','Adjusted F.P'),Result,",") 
Concat(Distinct(ThisItem.NameG.'Unadjusted F.P','Unadjusted F.P'),Result,",")
Concat(Distinct(ThisItem.NameG.'Final F.P','Final F.P'),Result,",")
Concat(Distinct(ThisItem.NameG.'Unique ID','Unique ID'),Result,",")

Notice that every row represents the Text property of the Label corresponding to each column.

2021-03-15-01.png

Regards,

Qi

Best Regards,
Qi

View solution in original post

3 REPLIES 3
RandyHayes
Super User
Super User

@Anonymous 

What is it that you are trying to achieve?

Each column in your collection is going to have a table with Result as its column.

 

Since you are using a Collection, this would be a table.  If you are only using one record in your collection, I would consider using a variable instead.

Set(
    projectnames,
    {
        projectname: Distinct('F.P Details of Module', 'Project Name'),
        adjustedfp: Distinct('F.P Details of Module', 'Adjusted F.P'),
        unadjustedfp: Distinct('F.P Details of Module', 'Unadjusted F.P'),
        finalfp: Distinct('F.P Details of Module', 'Final F.P'),
        unqiueid: Distinct('F.P Details of Module', 'Unique ID')
    }
)

Then for your Gallery Items property:

projectNames.projectname

Will provide your gallery with a table of Result columns based on the Distinct.

 

Not sure if that is what you are trying to achieve, but based on the formula you provided, this should get you that.

 

I hope this is helpful for you.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!
Anonymous
Not applicable

@RandyHayes what I am trying to achieve is to create a collection of distinct project name along with other values that can be viewed inside of a gallery. 
Project Name   Final F.P  unique id

ABCD                1.2              3456

XYZ                    1.5             4544

 

From your approach of using a variable also produces table records and thus I am not able to use it in gallery.image.png

Hi@Jayant2

Based on the issue that you mentioned, do you want to create a collection based on the distinct project name?

Could you please share a bit more about the 'F.P Details of Module'?

From your description, I think you want to display the distinct result based on the project name, every section in the Gallery will display a distinct project name and each Label within will display the corresponding distinct other column values.

If my understanding is correct, I think you should directly use the GroupBy () rather than the Collect().

In my scenario, all the column type are Text type.

Set the Items property of the Gallery as below:

GroupBy('F.P Details of Module',"ProjectName","NameG")

Set Text property of the Label within as below:

ThisItem.ProjectName // for the distinct ProjectName 
Concat(Distinct(ThisItem.NameG.'Adjusted F.P','Adjusted F.P'),Result,",") 
Concat(Distinct(ThisItem.NameG.'Unadjusted F.P','Unadjusted F.P'),Result,",")
Concat(Distinct(ThisItem.NameG.'Final F.P','Final F.P'),Result,",")
Concat(Distinct(ThisItem.NameG.'Unique ID','Unique ID'),Result,",")

Notice that every row represents the Text property of the Label corresponding to each column.

2021-03-15-01.png

Regards,

Qi

Best Regards,
Qi

Helpful resources

Announcements
Power Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Community Call Conversations

Introducing the Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Top Kudoed Authors
Users online (4,248)