cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
martinav
Super User
Super User

Can I not drop and add column with the same name?

Why is this broken?

 

 

ClearCollect(NextDataItems,RenameColumns(FirstN(Filter(temporary_assign_wo,Updated<>2 And !IsBlank(_SNValve)  ),Value(TextInput6.Text)),"SN_List","SN_List_Del"));
AddColumns(NextDataItems,"SN_List","d")

 

 

martinav_0-1633533134791.png

This works fine if I give the new column a different name.

I initially used DropColumns() but it resulted in the same issue.  Renaming it out of the way doesnt work either.

1 ACCEPTED SOLUTION

Accepted Solutions

@WarrenBelz 

 

Nope, I didnt. I ended up having to make a collection and doing the formulas in a separate ForAll(Collect()) nested function to get it done.  Not my preference, but its a one-off activity, so it was good enough.


Thanks for your help.

View solution in original post

13 REPLIES 13
Alex_10
Super User
Super User

@martinav 

 

ClearCollect(NextDataItems,
    AddColumns(
        DropColumns(
            AddColumns(
                FirstN(
                  Filter( temporary_assign_wo, Updated<>2 && !IsBlank(_SNValve) ),
                  Value(TextInput6.Text)
                ),
                "SN_List_Del", SN_List
            ),
            "SN_List"
        ),
        "SN_List", "d"
    )
);

 

 

martinav
Super User
Super User

@Alex_10 ,

 

Yep, thats what I did the first time.  Same result.  It is intuitively correct, but no workie.

 

martinav_0-1633543677805.png

Its all happy if I change the name...  same issue.  It MUST be the same name, so I can do a patch back to a SQL list with identical column names.

 

martinav_1-1633543756799.png

 

 

Alex_10
Super User
Super User

@martinav 

i suspect DropColums does not really deletes the column if datasource is SP, just hides it.

 

the only solution i have here is taking a full control over the result collection:

 

Clear(NextDataItems);
ForAll(
    FirstN(
        Filter( temporary_assign_wo, Updated<>2 && !IsBlank(_SNValve) ),
        Value(TextInput6.Text)
    ) As ThisSN,

    Collect(NextDataItems,
        {
            Title: ThisSN.Title,
            SN_List_Del: ThisSN.SN_List,
            SN_List: "d"
        }
    )
)

 

@Alex_10 ,

 

Yea, I was hoping to avoid that.  There are like 25 columns.  Thats a LOTTA stuff.  

 

Well, anyway.

 

Thanks

Hi @martinav ,

This should work

With(
   {
      wList:
      DropColumns(
         temporary_assign_wo,
         "SN_List"
      )
   },
   ClearCollect(
      NextDataItems,
      AddColumns(
         FirstN(
            Filter(
               wList,            
               Updated <> 2 And !IsBlank(_SNValve)
            ),
            Value(TextInput6.Text)
         ),
         "SN_List",
         "d"
      )
   )
)

Note you have a Delegation limitation with Add/Drop columns but you already had that with both of your filter criteria and FirstN

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

 

@WarrenBelz ,

 

Another great idea.  However, same result.  It still thinks its there.  I moved the filter around to make this a bit more simple where its broken.

 

 

With(
   {
      wList:
      DropColumns(
         FirstN(
            Filter(
               temporary_assign_wo,            
               Updated <> 2 And !IsBlank(_SNValve)
            ),
            Value(TextInput6.Text)
         ),
         "SN_List"
      )
   },
   ClearCollect(
      NextDataItems,
      AddColumns(wList,"SN_List","d")
   )
)

 

 

Result:

Same

martinav_0-1633963556460.png

Regarding delegation:  Its true, but for this purpose, it does not affect the purpose for which I'm using this.

Hi @martinav ,

I actually thought that would work, however the long way . . .

ClearCollect(
   colDrop,
   DropColumns(
      temporary_assign_wo,
      "SN_List"
   )
);
ClearCollect(
   NextDataItems,
   AddColumns(
      FirstN(
         Filter(
            colDrop,            
            Updated <> 2 And !IsBlank(_SNValve)
         ),
         Value(TextInput6.Text)
      ),
      "SN_List",
      "d"
   )
);
Clear(colDrop)

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

@WarrenBelz ,

 

I've been down this avenue as well.  I'm with you about the 'should work' situation.  I suspect this must have something to do with the fact the data comes from an SQL Table?  Well, if nothing makes sense, it something that doesnt make sense that is the explanation.

 

martinav_0-1633989069352.png

 

Hi @martinav ,

Got it to work with ShowColumns (RenameColumns fails too in SharePoint) in the first bit - and you are correct that it should work . . .

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

Helpful resources

Announcements
Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Power Apps Ideas

Check out the New Ideas Site

We are excited to announce a new way to share your ideas for Power Apps!

Top Solution Authors
Top Kudoed Authors
Users online (3,422)