cancel
Showing results for
Did you mean:
Frequent Visitor

## How can you calculate the Average in a DataTable Column?

I have a calculated column in a DataTable. DataTable1, the calculated column name is Trunc.

How do I calculate the average of Trunc?

Thanks,

Jim

1 ACCEPTED SOLUTION

Accepted Solutions
Super User

Hi @GandT

You may need to replace DataTable1 in your formula with the actual Items property of the datatable itself.  I found by experimentation, that if you use a gallery instead of a datatable, that your formula works but it requires Gallery1.AllItems, something that is not available in a datatable.  In the screenshot, the average works for the gallery but not the datatable.  However, if I replace DataTable2 in the formula with

Average(
Filter(
sales, Country=Dropdown2.Selected.Result),'Units Sold'
)
)

, then it works fine.  FYI, you can design a gallery to look identical to a datatable and it is a much more flexible control.

5 REPLIES 5
Super User

Hi @GandT Average(DataTable1,Trunc) this will be the average of the whole Trunc column

hope it helps

Frequent Visitor

Thanks I tried that again just now and I get this..

Super User

hi @GandT  seems like the type of data is text, try Average(DataTable1, Value(Trunc))

Super User

Hi @GandT

You may need to replace DataTable1 in your formula with the actual Items property of the datatable itself.  I found by experimentation, that if you use a gallery instead of a datatable, that your formula works but it requires Gallery1.AllItems, something that is not available in a datatable.  In the screenshot, the average works for the gallery but not the datatable.  However, if I replace DataTable2 in the formula with

Average(
Filter(
sales, Country=Dropdown2.Selected.Result),'Units Sold'
)
)

, then it works fine.  FYI, you can design a gallery to look identical to a datatable and it is a much more flexible control.

Frequent Visitor

Using your suggestion, I did finally get it to work. The data was in a Datatable, the interim calculations were in a Gallery and the Average was in a TextInput box.  Convoluted, but it worked.  Thanks again.

Announcements

#### Launching new user group features

Learn how to create your own user groups today!

#### Community & How To Videos

Check out the new Power Platform Community Connections gallery!

#### Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

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