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
Power Apps Africa Challenge 2022

Power Apps Africa Challenge

Your chance to join an engaging competition of Power Platform enthusiasts.

Super User 2 - 2022 Congratulations

Welcome Super Users

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

September Events 2022

Check out all of these events

Attend in person or online, there are incredible conferences and events happening all throughout the month of September.

Government Carousel

New forum: GCC, GCCH, DoD - Federal App Makers (FAM)

In response to the unique and evolving requirements of the United States public sector, Microsoft has created Power Apps US Government.

Users online (2,127)