cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
sasrsc
Resolver II
Resolver II

combine add columns

I have a button onSelect that adds 2 columns ... 
I'm sure it can be done easier than this... I need to add 2 columns from one data source to an existing table. Both tables have lots of columns.
I'm creating a collection as this needs to be used later and it's easier to create a new collection....
How would you combine this into "one step" as the Lookup is the same...

/* add occ in date */
ClearCollect(
    HotelsClaimedDetail1,
    AddColumns(
        HotelsClaimed As _HotelsClaimed,
        "OccInDate",
        LookUp(
            Hotels,
            PasskeyEventID = _HotelsClaimed.Title,
            'Occ In Date'
        )
    )
);
/* add occ out date - same source table */
ClearCollect(
    HotelsClaimedDetail2,
    AddColumns(
        HotelsClaimedDetail1 As _HotelsClaimed,
        "OccOutDate",
        LookUp(
            Hotels,
            PasskeyEventID = _HotelsClaimed.Title,
            'Occ Out Date'
        )
    )
);

 

1 ACCEPTED SOLUTION

Accepted Solutions
timl
Super User
Super User

Hi @sasrsc 

Here's one way to combine the 2 calls into one...

 

ClearCollect(
    HotelsClaimedDetail1,
    AddColumns(
        HotelsClaimed As _HotelsClaimed,
        "OccInDate",
        LookUp(
            Hotels,
            PasskeyEventID = _HotelsClaimed.Title,
            'Occ In Date'
        ),
        "OccOutDate",
        LookUp(
            Hotels,
            PasskeyEventID = _HotelsClaimed.Title,
            'Occ Out Date'
        )
    )
)

View solution in original post

2 REPLIES 2
timl
Super User
Super User

Hi @sasrsc 

Here's one way to combine the 2 calls into one...

 

ClearCollect(
    HotelsClaimedDetail1,
    AddColumns(
        HotelsClaimed As _HotelsClaimed,
        "OccInDate",
        LookUp(
            Hotels,
            PasskeyEventID = _HotelsClaimed.Title,
            'Occ In Date'
        ),
        "OccOutDate",
        LookUp(
            Hotels,
            PasskeyEventID = _HotelsClaimed.Title,
            'Occ Out Date'
        )
    )
)

View solution in original post

eka24
Super User
Super User

Use this:

ClearCollect(
    HotelsClaimedDetail1,
    AddColumns(
        HotelsClaimed As _HotelsClaimed,
        "OccInDate",
        LookUp(
            Hotels,
            PasskeyEventID = _HotelsClaimed.Title,
            'Occ In Date'
        ),
                "OccOutDate",
        LookUp(
            Hotels,
            PasskeyEventID = _HotelsClaimed.Title,
            'Occ Out Date'
        )
    )
);

------------

If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users find it.

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

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.

Users online (2,940)