cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
martinav
Community Champion
Community Champion

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
martinav
Community Champion
Community Champion

@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
Community Champion
Community Champion

@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"
        }
    )
)

 

martinav
Community Champion
Community Champion

@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.

 

martinav
Community Champion
Community Champion

@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.

martinav
Community Champion
Community Champion

@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
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!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Top Solution Authors
Top Kudoed Authors
Users online (1,846)