cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
ruth
Helper IV
Helper IV

creating a calculated value in collection

I'm trying to add a column to a collection which is a concatenated value.  Very basic collection that stores contact info from a sharepoint list. I want FullName which concatenates the First, Middle, Last. The only issue is that the concatenated value is being stored as a table vs. a cell similar to the other values. So each row has the same table of values for fullname, then the individual values for the remaining columns - address, city, state, etc.

 

Why is this? Is there a way to have each cell store a concatenated value based on the values of that row?

 

ruth

1 ACCEPTED SOLUTION

Accepted Solutions
timl
Super User III
Super User III

Hi @ruth 

What formula are you using to add your collection?

The AddColumns function will add a column to a collection, like so:

AddColumns(yourCollection, 
            "Fullname",
            Firstname & " " & Lastname
)

https://docs.microsoft.com/en-gb/powerapps/maker/canvas-apps/functions/function-table-shaping

 

View solution in original post

6 REPLIES 6
eka24
Super User III
Super User III

Can you share your code that is giving you issues?

------------

If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users find it.

Consider Checking My Youtube Channel  

timl
Super User III
Super User III

Hi @ruth 

What formula are you using to add your collection?

The AddColumns function will add a column to a collection, like so:

AddColumns(yourCollection, 
            "Fullname",
            Firstname & " " & Lastname
)

https://docs.microsoft.com/en-gb/powerapps/maker/canvas-apps/functions/function-table-shaping

 

View solution in original post

I have gone through so many iterations, but I think I finally got it.  here is what I had:

ClearCollect( cContact, {ID: tblContact.conID, FullName: Concatenate( tblContact.conLast, ", ", tblContact.conFirst, " ", tblContact.conMiddle ), Address: tblContact.conAddress, CityStateZip: Concatenate( tblContact.conCity, ", ", tblContact.conState, " ", tblContact.conZip )} )

 

Here is what I finally got to work:

ClearCollect(
aContact,
ShowColumns(
tblContact,
"conFirst",
"conMiddle",
"conLast",
"conAddress",
"conCity",
"conState",
"conZip"
)
);
ClearCollect(
bContact,
AddColumns(
aContact,
"FullName",
Concatenate(
conLast,
", ",
conFirst,
" ",
conMiddle
)
)
);

Pstork1
Dual Super User III
Dual Super User III

The AddColumns() alone will return a table of data, but won't make a change to the original collection.  So you need to add a ClearCollect(newCollectionName, AddColumns) around the AddColumns.  Once the schema of a collection is created you can't change it.  but the following two functions work for me.

ClearCollect(myData,{First: "Paul", Last: "Stork"},{First: "John", Last: "Doe"},{First: "Abe", Last: "Lincoln"})
ClearCollect(newData,AddColumns(myData,"Full",Concatenate(First," ",Last)))


-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

@Pstork1 , Thanks. I think that was one of my original problems.

timl
Super User III
Super User III

You're spot on there @Pstork1 , thanks for the clarification. That was something I was going to expand on once I saw the formula that added the child tables. I get how how what I said there was confusing.

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

secondImage

Demo Extravaganza is Back!

We are excited to announce that Demo Extravaganza for 2021 has started!

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

Power Apps June 2021

June Power Apps Community Call

Did you miss the call? Check out the recording here!

Top Solution Authors
Top Kudoed Authors
Users online (64,437)