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 III
Super User III

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 III
Super User III

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 III
Super User III

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
PA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

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.

R2 (Green) 768 x 460px.png

Microsoft Dynamics 365 & Power Platform User Professionals

DynamicsCon is a FREE, 4 half-day virtual learning experience for 11,000+ Microsoft Business Application users and professionals.

Users online (2,141)