cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
NeohLooi
Helper II
Helper II

Average function

I have two data field which is A and B, I want to calculate the average between them. For example A has value of 3 and B has value of 4 , the average function should be return 3.5 into my SQL database, but it instead return 3. I set the average column in my SQL database as float.  Is that anything I configure wrongly? Any help will be thanks. 

1 ACCEPTED SOLUTION

Accepted Solutions

@NeohLooi 

I know what the issue is.  SampleB is not yet present in the database.  The whole record gets updated in dbo.User at once meaning SampleB is not yet available.

 

Do this instead: 

UpdateIf(
    '[dbo].[User]',
    UserNo = TextInput13.Text, 
    {
        SampleB:Value(TextInput16.Text),
        Average:Average([SampleA,Value(TextInput16.Text)],Value)
    }
)

 

---
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

3 REPLIES 3
mdevaney
Super User
Super User

@NeohLoo 

When typing this code into the Text property of a label I received the output 3.5.

Average([3,4],Value)

 

Could you please share the code used to create an AVERAGE from your SQL table?

 

---
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."

 

UpdateIf('[dbo].[User]', UserNo = TextInput13.Text, {SampleB:Value(TextInput16.Text),Average:Average([SampleA,SampleB],Value)}


I try to use update function to allow user enter SampleB value and the Average column will calculate it with the SampleA existed in the database. Is that this will able to run? Any alternative?

@NeohLooi 

I know what the issue is.  SampleB is not yet present in the database.  The whole record gets updated in dbo.User at once meaning SampleB is not yet available.

 

Do this instead: 

UpdateIf(
    '[dbo].[User]',
    UserNo = TextInput13.Text, 
    {
        SampleB:Value(TextInput16.Text),
        Average:Average([SampleA,Value(TextInput16.Text)],Value)
    }
)

 

---
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
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

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 (3,019)