cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
ErikParmlind
Helper I
Helper I

Using SUM in a Gallery

I have a data source with 5 columns, A through E. In these columns there can be numerical values. I wish to sum all the values that may be in the columns and display them in a Gallery. The gallery should have five rows, with each row showing the number of values in the columns. 

 

I have a formula that resembles this one: 

Sum(Filter(...;...selected.value="...");fieldname) 

If I write "ColumnA" to fieldname it works for that one case. But if I try to add a variable which changes from ColumnA, B, C depending on which row of Gallery it is in nothing is shown from the Sum. 

Can I have a variable for the fieldname of the SUM function in Power Apps? Or is there another way of doing this?

 

Thank you, 
 

1 ACCEPTED SOLUTION

Accepted Solutions
mdevaney
Super User III
Super User III

@ErikParmlind 

Have you considered replacing this

fieldname

 

With a SWITCH function?

Swtich(
    ThisItem.SomeColumnName,
    "A",fieldNameA,
    "B",fieldNameB,
    "C",fieldNameC,
    "D",fieldNameD,
    "E",fieldNameE
)

 

Link to Official MS Documenation for SWITCH

https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/functions/function-if

 

---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

View solution in original post

1 REPLY 1
mdevaney
Super User III
Super User III

@ErikParmlind 

Have you considered replacing this

fieldname

 

With a SWITCH function?

Swtich(
    ThisItem.SomeColumnName,
    "A",fieldNameA,
    "B",fieldNameB,
    "C",fieldNameC,
    "D",fieldNameD,
    "E",fieldNameE
)

 

Link to Official MS Documenation for SWITCH

https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/functions/function-if

 

---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

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

MBAS Attendee Badge

Claim Your Badge & Digital Swag!

Check out how to claim yours today!

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

Top Solution Authors
Top Kudoed Authors
Users online (53,245)