cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
JC75NATS
Advocate II
Advocate II

Patch a separate list as a transpose of a collection from another list

I have two SP Lists.

 

One list has Columns: Title, Status1 - and some other columns

The records in the list are about 20 items - in Title each record has a unique name. 

09L, 09R, 27L, 27R etc

 

The second list has a column for each one of the Title records from List 1 - so Columns: 09L, 09R, 27L 27R etc. plus a column Called last update.

 

The powerapp uses List 1 for a status dashboard - so just updates the status 1 column for each record, this is done through a collection of the list, which I just Collect back to the SPlist when user presses update button. That bit all works fine.

 

What I want to do is when the user selects update button - that it also writes a single Record in list 2 for each of the records in list 1 populating the columns in list 2 with the status1 value from list 1 under the column name that matches the title name in list 2, so in essence a log entry of the updates.

 

How do I do this? 

 

In essence its a bit like transpose in excel?

list 1

TitleStatus1other columns not neeeded for list 2
09LGreen 
09ROrange 
27L

Red

 

 

List 2:

LastUpdate09L  09R27L
01/01/1880GreenOrangeRed

                  

1 ACCEPTED SOLUTION

Accepted Solutions
v-xiaochen-msft
Community Support
Community Support

Hi @JC75NATS ,

 

Could you tell me:

Do you want to generate a new record in list2 after clicking the button, it is not difficult to achieve?

Is the data type of the Status1 field Single line of text ?

 

Firstly, if the above assumptions are true, the point is to use the patch() function and lookup() function to add a record in list2. I suggest you add some code to the button to satisfy this function.

 

Secondly, In order to help you solve the problem, I assumed some conditions and did a test for your reference:

I assume:

  • There are three records in list1, their title values are 09L, 09R and 27L.
  • I assume the data type of ‘Status1 field in LIST16 is Single line of text.

 

1\ Show my list

v-xiaochen-msft_0-1605775631846.png

 

// LIST16 corresponds to your list 1

v-xiaochen-msft_1-1605775631848.png

 

// LIST17 corresponds to your List 2

 

2\ Add some code to onselect property of the button:

Patch(

    LIST17,

    Defaults(LIST17),

    {

        Title: "1",

        '09L': LookUp(

            LIST16,

            Title = "09L"

        ).Status1,

        '09R': LookUp(

            LIST16,

            Title = "09R"

        ).Status1,

        '27L': LookUp(

            LIST16,

            Title = "27L"

        ).Status1,

        LastUpdate: Today()

    }

)

 

3\ The result is as follows:

v-xiaochen-msft_2-1605775631850.png

 

 

Best Regards,

Wearsky

View solution in original post

1 REPLY 1
v-xiaochen-msft
Community Support
Community Support

Hi @JC75NATS ,

 

Could you tell me:

Do you want to generate a new record in list2 after clicking the button, it is not difficult to achieve?

Is the data type of the Status1 field Single line of text ?

 

Firstly, if the above assumptions are true, the point is to use the patch() function and lookup() function to add a record in list2. I suggest you add some code to the button to satisfy this function.

 

Secondly, In order to help you solve the problem, I assumed some conditions and did a test for your reference:

I assume:

  • There are three records in list1, their title values are 09L, 09R and 27L.
  • I assume the data type of ‘Status1 field in LIST16 is Single line of text.

 

1\ Show my list

v-xiaochen-msft_0-1605775631846.png

 

// LIST16 corresponds to your list 1

v-xiaochen-msft_1-1605775631848.png

 

// LIST17 corresponds to your List 2

 

2\ Add some code to onselect property of the button:

Patch(

    LIST17,

    Defaults(LIST17),

    {

        Title: "1",

        '09L': LookUp(

            LIST16,

            Title = "09L"

        ).Status1,

        '09R': LookUp(

            LIST16,

            Title = "09R"

        ).Status1,

        '27L': LookUp(

            LIST16,

            Title = "27L"

        ).Status1,

        LastUpdate: Today()

    }

)

 

3\ The result is as follows:

v-xiaochen-msft_2-1605775631850.png

 

 

Best Regards,

Wearsky

Helpful resources

Announcements
Super User 2 - 2022 Congratulations 768x460.png

Welcome Super Users

The Super User program for 2022 - Season 2 has kicked off!

Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

<
Users online (3,856)