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

Sum of added column

Hello, So i have a data table which i have to add a number of extra columns to. One being a percentage of the score vs the potential score. I now want a sum of the filtered data table (so it only shows the sum for that month for that agent) but i can not work it out I have tried, but it doesnt work: 

 

Sum(Filter(Table1, Agent ' = Dropdown2.Selected.'Agent Name ', Label4.Text = Text(MonthStats)), Percentage)

 

This is the formula in the data table: 

Filter(AddColumns(AddColumns(Table1, "MonthStats", Text(Month(Date_x0020_)), "FormattedDate", Text(Date_x0020_, "[$-en-GB]dd/mm/yyyy"), "Score", If('Did the response resolve their enquiry?'= "Yes", 10, 0), "PotentialScore", 10),"Percentage", Sum((Score / PotentialScore)*100)),'Agent ' = Dropdown2.Selected.'Agent Name ', Label4.Text = Text(MonthStats))

1 ACCEPTED SOLUTION

Accepted Solutions
RandyHayes
Super User
Super User

@Coletteb425 

The issue is that the DataTable does not serve as a datasource.  Galleries have an AllItems property which can be used in this way, but DataTables do not.  Therefore, you will not have access to your added columns outside of the table.

 

What I would recommend is to create a collection with the formula you have.  You can place this in the OnVisible action or some other place as you see fit - perhaps needed in your OnChange of the Agent dropdown.

 

ClearCollect(colMyData, 
Filter(
AddColumns(
AddColumns(Table1,
"MonthStats", Text(Month(Date_x0020_)),
"FormattedDate", Text(Date_x0020_, "[$-en-GB]dd/mm/yyyy"),
"Score", If('Did the response resolve their enquiry?'= "Yes", 10, 0),
"PotentialScore", 10
),
"Percentage", Sum((Score / PotentialScore)*100)
),
'Agent ' = Dropdown2.Selected.'Agent Name ', Label4.Text = Text(MonthStats)
)
)

Then set your datatable items to colMyData

Now you can use that collection in your sum formula:

 

Sum(colMyData, Percentage)

By the way - in this formula, we're not filtering by agent or month because the collection is already filtered by that.

 

I hope this is helpful for you.

 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

View solution in original post

2 REPLIES 2
RandyHayes
Super User
Super User

@Coletteb425 

The issue is that the DataTable does not serve as a datasource.  Galleries have an AllItems property which can be used in this way, but DataTables do not.  Therefore, you will not have access to your added columns outside of the table.

 

What I would recommend is to create a collection with the formula you have.  You can place this in the OnVisible action or some other place as you see fit - perhaps needed in your OnChange of the Agent dropdown.

 

ClearCollect(colMyData, 
Filter(
AddColumns(
AddColumns(Table1,
"MonthStats", Text(Month(Date_x0020_)),
"FormattedDate", Text(Date_x0020_, "[$-en-GB]dd/mm/yyyy"),
"Score", If('Did the response resolve their enquiry?'= "Yes", 10, 0),
"PotentialScore", 10
),
"Percentage", Sum((Score / PotentialScore)*100)
),
'Agent ' = Dropdown2.Selected.'Agent Name ', Label4.Text = Text(MonthStats)
)
)

Then set your datatable items to colMyData

Now you can use that collection in your sum formula:

 

Sum(colMyData, Percentage)

By the way - in this formula, we're not filtering by agent or month because the collection is already filtered by that.

 

I hope this is helpful for you.

 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

That is exactly what i was after I thought it would need a collection somewhere but couldnt work out how that would work with me changing the dropdowns all the time but on change for both dropdowns works perfectly! Thanks 

Helpful resources

Announcements
Ignite 2022

WHAT’S NEXT AT MICROSOFT IGNITE 2022

Explore the latest innovations, learn from product experts and partners, level up your skillset, and create connections from around the world.

Power Apps Africa Challenge 2022

Power Apps Africa Challenge

Your chance to join an engaging competition of Power Platform enthusiasts.

Top Kudoed Authors
Users online (3,410)