web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Apps
Answered

how to calculate

(0) ShareShare
ReportReport
Posted on by 73

Hey All,

 

Here i am really stucked. Now my app is a data collection canvas app and some point my customer wants to see a result of calculation of 3 different properties. I will try to explain it;

 

in volumes screen there is a gallery called gallery8 which contains a label (takes the value from 2 datepickers and shows the difference between them in the format year. i used this code on the items property of the gallery8

 

With({nbrYears:Year(DatePickerenddate.SelectedDate)-Year(DatePickerstartdate.SelectedDate)},
Sequence(nbrYears+1,1,1))

and in the text property of the label controller in the gallery8 i used this;

 

Year(DatePickerstartdate.SelectedDate)-1+ThisItem.Value

 

if i choose the date as 01/01/2024 from the 1st datepicker and the from the second like 01/01/2030, this label will show in the gallery like 2024, 2025, 2026, 2027, 2028, 2029 and 2030 vertically. Beside this label there are 2 textinputs which is filled by the user. the textinput i am using in the calculation is called "QtyOfVehicule". In this screen there is another textinput outside the gallery8 which the user enters the percentage of the volume entered in the "QtyOfVehicule" textinput called AffectationCoefficient. 

 

In the articles screen (second screen) there is another gallery which in the same manner shows the years. there is again a textinput outside the gallery named "QtyPerVehicule" where the user again enters a percentage of the volume to indicate how many there will be per vehicle for each QtyOfVehicule. I need to show the result of this calculation ; QtyOfVehicule * QtyPerVehicule * AffectationCoefficien.

 

For example for the QtyOfVehicule = 50000, AffectationCoefficient = 100% and QtyPerVehicule = 200%. my formula is this; 

 
IfError(
With({
 AffectationCoefficient:Value(affectationCoefficient.Text)
 ,QtyOfVehicule:ThisItem.Value
 ,QtyPerVehicule:Value(QtyPerVehicules.Text)
},
QtyOfVehicule*(AffectationCoefficient)*(QtyPerVehicule)
),
"")

it should give 100000 where i recieve 20000.

 

Do not know how to fix this. Does anyone?

 

Thanks in advance

Categories:
  • Verified answer
    v-jefferni Profile Picture
    Microsoft Employee on at

    Hi @agorkemt ,

     

    Is this the result you are getting now?

    vjefferni_0-1712654033954.png

     

    If you want to achieve the goal as below:

    vjefferni_1-1712654417177.png

     

    You need to change Items property of the Gallery on articles screen:

    ForAll(
     Gallery8.AllItems,
     {
     Year: Title8.Text,
     Result: IfError(
     With(
     {
     AffectationCoefficient: Value(affectationCoefficient.Text),
     QtyOfVehicule: Value(QtyOfVehicule.Text),
     QtyPerVehicule: Value(QtyPerVehicules.Text)
     },
     QtyOfVehicule * AffectationCoefficient * QtyPerVehicule
     ),
     ""
     )
     }
    )

     

    and Gallery settings:

    vjefferni_2-1712654984281.png

     

    Best regards,

  • agorkemt Profile Picture
    73 on at

    Thank you very much for the answer @v-jefferni . 

     

    Concerning your question yes! exactly what I recieved. 

     

    Only thing I changed with your code was to add a division to the code like this;

    QtyOfVehicule * (AffectationCoefficient/100) * (QtyPerVehicule/100)

     

    I didn't mentioned maybe but the "AffectationCoefficien" and "QtyPerVehicule" controllers in fact are percentages. Now It works very well!

     

    Thank you very much. 

     

     

     

     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 243 Super User 2026 Season 2

#2
WarrenBelz Profile Picture

WarrenBelz 190 Most Valuable Professional

#3
Mohsin Ali Profile Picture

Mohsin Ali 135

Last 30 days Overall leaderboard