cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
morall
Microsoft
Microsoft

combining two collections

ClearCollect(
    test1,
    Choices('HM InterviewStatus')
);

 

this turns an option set into a collection:

 

ClearCollect(
    test2,
    ForAll(
        test1,
        CountIf(hm_request_can_id, InterviewStatus = Value)
    )
);

 

this loops through that collection, and counts how many times each value shows up in hm_request_can_id

 

Is there a way to combine these two collections so that its 1 collection with 2 columns: status & count?

1 ACCEPTED SOLUTION

Accepted Solutions

@morall 

Perfect - thank you for the details.

So, let's start basic and build up.

ClearCollect(
    test3,
    AddColumns(
        RenameColumns(Choices('HM InterviewStatus'), "Value", "status"),
        "count", 1)
    )
);

Using the above formula, you should have a two column collection called test3 that should have 2 columns - "status" and "count" each row will have a count of 1 with this formula.

 

I do see a typo in my original formula, so try this then instead on the "full speed ahead" formula:

ClearCollect(
    test3,
    AddColumns(
        RenameColumns(Choices('HM InterviewStatus'), "Value", "status"),
        "count", CountRows(Filter(hm_request_can_id, InterviewStatus=status))
    )
);

It was that I simply had Status instead of status.

 

So, let's see what you get with formula 1 and then the second formula.

 

_____________________________________________________________________________________
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.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

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

View solution in original post

11 REPLIES 11
RandyHayes
Super User
Super User

@morall 

Yes, but can you explain what hm_request_can_id is?  Is that a datasource?

 

If so, then this formula would give you what you need:

AddColumns(
    RenameColumns(Choices('HM InterviewStatus'), "Value", "status"),
    "count", CountRows(Filter(hm_request_can_id, InterviewStatus = status))
)

 

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.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

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

@RandyHayes it is a collection.

 

 

ClearCollect(
    hm_request_can_id,
    Sort(
        AddColumns(
            Filter(
                DataSource
                Candidate.ID in tessa_candidates,
                'Created On' > DateAdd(
                    Now(),
                    -90,
                    Days
                )
            ),
            "custom_candidate_id",
            Candidate.ID
        ),
        'Created On',
        Descending
    )
);

 

 

 

 

@RandyHayes 

 

I'm getting an empty collection:

 

ClearCollect(
    test3,
    AddColumns(
        RenameColumns(Choices('HM InterviewStatus'), "Value", "status"),
        "count", CountRows(Filter(hm_request_can_id, InterviewStatus=Status))
    )
);

 

I feel like I'm not doing the AddColumns(), the first parameter is expecting a datasource and I'm asking it to rename a column....

 

@morall 

RenameColumns is a datasource.  It returns a table of the Choices function.

 

Oh sorry though, I didn't even notice - you are specifying a Datasource for Choices but no column to get choices from.  What Column do you want the Choices from?  You need to specify that.

_____________________________________________________________________________________
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.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

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

@RandyHayes 

 

Choices('HM Interested')

is an option set 

 

I'm trying to create a collection that has two columns:
Column 1:

Choices from option Set

 

Column 2:

Count how many times that option appears in the other data source

 

@morall 

Yes, I understood that.

The formula I provided should give you what you want.  Since it is not, let's explore a little.

You originally had a formula of:

ClearCollect(
    test1,
    Choices('HM InterviewStatus')
);

When you had that, did test1 have values?  And specifically, was test1 a table with a single column called "Value"?

I had assumed Value based on your second formula. 

_____________________________________________________________________________________
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.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

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

@Randy 

 

Yes, your intuition is correct. it returned a collection with 1 column that had the option set value. I can't quite figure out how to add a column to that 🙂 

 

Screen Shot 2020-09-25 at 7.15.24 PM.png

ClearCollect(
    test3,
    AddColumns(
        RenameColumns(Choices('HM InterviewStatus'), "Value", "status"),
        "count", CountRows(Filter(hm_request_can_id, InterviewStatus=Status))
    )
);

 

this is what I see:

 

Screen Shot 2020-09-25 at 7.18.19 PM.png

@morall 

Perfect - thank you for the details.

So, let's start basic and build up.

ClearCollect(
    test3,
    AddColumns(
        RenameColumns(Choices('HM InterviewStatus'), "Value", "status"),
        "count", 1)
    )
);

Using the above formula, you should have a two column collection called test3 that should have 2 columns - "status" and "count" each row will have a count of 1 with this formula.

 

I do see a typo in my original formula, so try this then instead on the "full speed ahead" formula:

ClearCollect(
    test3,
    AddColumns(
        RenameColumns(Choices('HM InterviewStatus'), "Value", "status"),
        "count", CountRows(Filter(hm_request_can_id, InterviewStatus=status))
    )
);

It was that I simply had Status instead of status.

 

So, let's see what you get with formula 1 and then the second formula.

 

_____________________________________________________________________________________
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.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

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

View solution in original post

Helpful resources

Announcements
PA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

secondImage

Power Apps Community Call

Please join us on Wednesday, October 20th, at 8a PDT. Come and learn from our amazing speakers!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Welcome Super Users.jpg

Super User Season 2

Congratulations, the new Super User Season 2 for 2021 has started!

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.

Top Solution Authors
Top Kudoed Authors
Users online (1,584)