cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
BCLS776
Frequent Visitor

Removing commas from text strings in collection

Hi, I am exporting data from a collection inside PowerApps to a CSV file, which works well as long as the data does not contain extra commas. I have a column in my collection that contains user-typed data that often contains commas, so I want to strip those out and replace them with another punctuation mark that is CSV-friendly such as a semicolon.

 

I've tried a ForAll with a nested Patch and Substitute, but Substitute cannot operate on the same data source as used in the ForAll:

 

 

ForAll(col_Data,
        Patch(
            col_Data,
            ThisRecord,
            {
            WorkDesc: Substitute(ThisRecord.WorkDesc,",",";")
            }
        )
);

 

 

 

I tried using the Substitute function with an Addcolumns to paste on a new column to this collection, but since it operates on the whole column it ends up nesting the entire new column in each record.

Does anyone have other ideas I can try to screen out these extra commas?

 

 

1 ACCEPTED SOLUTION

Accepted Solutions

Hi @BCLS776 ,

Seems it needs another Degree of Separation . . .

With(
   {wData: col_Data},
   ForAll(
      wData As aData,
      Patch(
         col_Data,
         {ID: aData.ID},
         {
            WorkDesc: 
            Substitute(
               aData.WorkDesc,
               ",",
               ";"
            )
         }
      )
   )
)

 

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.

View solution in original post

4 REPLIES 4
WarrenBelz
Super User III
Super User III

Hi @BCLS776 ,

Try this - assuming you have an ID field in your collection.

ForAll(
   col_Data As aData,
   Patch(
      col_Data,
      {ID:aData.ID},
      {
         WorkDesc: 
         Substitute(
            aData.WorkDesc,
             ",",
             ";"
         )
      )
   }
)

 

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 , thanks for the quick reply. I made the adjustment to scope handling as you suggested, but it still reports it "cannot operate on the same data source that is used in ForAll":

ForAll(
   col_Data As aData,
   Patch(
      col_Data,
      {ID:aData.ID},
      {
         WorkDesc: 
         Substitute(
            aData.WorkDesc,
             ",",
             ";"
         )
      }
   )
);

 Are there alternative ways to accomplish what I am trying to do with this?

Hi @BCLS776 ,

Seems it needs another Degree of Separation . . .

With(
   {wData: col_Data},
   ForAll(
      wData As aData,
      Patch(
         col_Data,
         {ID: aData.ID},
         {
            WorkDesc: 
            Substitute(
               aData.WorkDesc,
               ",",
               ";"
            )
         }
      )
   )
)

 

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.

View solution in original post

@WarrenBelz that worked great - thank you!

Helpful resources

Announcements
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

MBAS Attendee Badge

Claim Your Badge & Digital Swag!

Check out how to claim yours today!

secondImage

Are Your Ready?

Test your skills now with the Cloud Skill Challenge.

Top Solution Authors
Top Kudoed Authors
Users online (44,281)