cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
mmattar
Responsive Resident
Responsive Resident

How to split a value from a collection

Hello all,

 

I am trying to Split a value from a collection, example of the value from the collection: "4/16/2020 12:00 AM". I am trying to pick piece this string into  "4/16/2020" "12:00", and "AM" without using extra labels, I achieved this by storing the collection value into a label and then referring to the label i picked  the value apart. How can I do it straight from grabbing it from the collection itself.

 

Thanks

1 ACCEPTED SOLUTION

Accepted Solutions
mmattar
Responsive Resident
Responsive Resident

If anyone facing the same issue as i am, i just found it easier to store the split pieces as a variable rather than AddColumns to a collection, the addcolumns seems to be limited to what it can actually do. 

View solution in original post

5 REPLIES 5
mdevaney
Super User III
Super User III

@mmattar 

You could ADDCOLUMNS to your collection like this.  Then you could reference those columns in wherever needed.

AddColumns(
    your_collection_name,
    "Date", First(Split(your_column_name, " ")).Value,
    "Time", FirstN(Split(your_column_name, " "),2).Value,
    "AMPM", Last(Split(your_column_name, " ")).Value
);

 

Please let me know if you require more advice 🙂

mmattar
Responsive Resident
Responsive Resident

How can i go about adding these columns at the sametime as a OnSelect of a Gallery occurs that populates the collection  

@mmattar 

I would say to put the code I gave in the OnSelect property of the button.

mmattar
Responsive Resident
Responsive Resident

Hey yes i actually figured that part out, i am now noticing an error saying (Invalid Argument Type DateTime, Expecting Text). I wrapped it all in a Text() function and its still not working

mmattar
Responsive Resident
Responsive Resident

If anyone facing the same issue as i am, i just found it easier to store the split pieces as a variable rather than AddColumns to a collection, the addcolumns seems to be limited to what it can actually do. 

View solution in original post

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

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

V3_PVA CAmpaign Carousel.png

Community Challenge - Giveaways!

Participate in the Power Virtual Agents Community Challenge

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Top Solution Authors
Top Kudoed Authors
Users online (2,675)