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

Update Collection with a reference to another column

Hello All,

 

In one of my app i'm trying to update an entire column based on another column.

Here my collection :

 

 

NameAgeYear Of birth
Emilie300
David350

 

I want to have the collection below :

 

 

NameAgeYear Of birth
Emilie301988
David351983

 

Do you know how can it be done ?


Thanks

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Microsoft
Microsoft

Re: Update Collection with a reference to another column

No problem, indeed the age is more complex and as far as I can see, impossible to figure out YOB just from an age 🙂

 

As for the updateif syntax:

 

UpdateIf(CollectionName, Condition, {field_to_update: value})

To update multiple fields of the same row

UpdateIf(CollectionName, Condition, {field_to_update: value, field_to_update: value,field_to_update: value})

So the formula for "in collectable where year of birth =0, update year of birth value to today's year minus age"

UpdateIf(CollectTable, 
'Year Of birth'=0, {'Year Of birth': Year(Today())-Age})

 

 

Kind regards


RT

View solution in original post

4 REPLIES 4
Highlighted
Microsoft
Microsoft

Re: Update Collection with a reference to another column

Hi leumas09,


The answer might depend on what your ultimate outcome is...but just to update a collection you can use  Update or UpdateIf()

 

Very simply (and not taking your intended result) into account:

UpdateIf(collectTable1, conditionToCheck, {ColumnToUpdate:  value})

So you could update all rows where 'Year Of birth' =0, and for each row then do a calc to return the year of birth based on the Age given and update the 'Year Of birth' column with that result.

 

However, this will look slightly more complicated if I take what you're trying to do and apply it with the outcome in mind - I've removed the initial formula I put here because it's not actually possible to accurately depict a date of birth without knowing in which month and on what day a person was born.

 

You can guess by using the end of the year as the starting point and subtracting 30 years from it, but if the person is 30 today and 31 tomorrow, the date of birth will change - which is obviously not the case in real life.  

 

Will play a bit with the formula and post back, but for now this should answer your update question 🙂

 

Hope this helps,

 

RT

 

Highlighted
Frequent Visitor

Re: Update Collection with a reference to another column

Hi RusselThomas,

 

Thanks for your answer. Indeed the age is a little more complex, but it was an exemple (I thought simple) to explain my issue.

What I don't figure out is how to do is to reference another column in the update ?

 

If I was doing this by code, i will to something like that

 

 

Foreach (item in collectTable1) {
  item.YearOfBirth = today.year - item.age
}

 

 

Sorry, my question wasn't clear enough on my first message. How, in the update or in the forAll function, can I achieve to reference another column in my formula ?

 

Thanks.

Highlighted
Microsoft
Microsoft

Re: Update Collection with a reference to another column

No problem, indeed the age is more complex and as far as I can see, impossible to figure out YOB just from an age 🙂

 

As for the updateif syntax:

 

UpdateIf(CollectionName, Condition, {field_to_update: value})

To update multiple fields of the same row

UpdateIf(CollectionName, Condition, {field_to_update: value, field_to_update: value,field_to_update: value})

So the formula for "in collectable where year of birth =0, update year of birth value to today's year minus age"

UpdateIf(CollectTable, 
'Year Of birth'=0, {'Year Of birth': Year(Today())-Age})

 

 

Kind regards


RT

View solution in original post

Highlighted
Frequent Visitor

Re: Update Collection with a reference to another column

Thanks RusselThomas it working well Smiley Very Happy

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Find your favorite faces from the community presenting at the Power Platform Community Conference!

Watch Now

Experience what’s next for Power Apps

See the latest Power Apps innovations, updates, and demos from the Microsoft Business Applications Launch Event.

Power Platform ISV Studio

Power Platform ISV Studio

ISV Studio is designed to become the go-to Power Platform destination for ISV’s to monitor & manage published applications.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors
Users online (5,721)