66
Views
7
Comments
If expressions for calculations

Hi guys, I have been trying to write an expression for an action button.  

Basically, what I have is a row of text inputs for numbers (A1-A6), I have a subtotal box (ASubTot) which calculates the total from all these.  I am trying to create an action/expression that when i click the button it will take this sub total, if it is less or equal to a certain number (say 500) then there will be no change but if the SubTot is over 500 then it would be whatever the SubTot is + 125.

I just keep falling down at the expression building :(

Any help would be greatly appreciated

UserImage.jpg
keith farwell

to add:  I would have another field below the ASubTot with the calculated result in it 

2020-11-13 07-48-15
Khuong Truong

Hi Keith,

I think in this case it will be easier to help if you share your .oml file.

Or at least any screenshot of the screen and logic that you did tried.

Regards,

Khuong

2022-02-08 09-40-14
Chandrashekhar Mankar

Hi Keith, please share your OML so that we can have a look at it and give best possible solution.

2021-09-06 15-09-53
Dorine Boudry
 
MVP

Hi Keith,

If you do your calculations in an action, you can just take as many steps as you like, with local variables holding your intermediate results.

So, is it something specific of Outsystems you are struggling with, or is it the math ?

I would say

Sum = 0

Sum = A1 + A2 + ....

(e.g. if your values are in a list, loop the list and inside the loop add each value to Sum)

Surcharge = If(Sum > 500, 125, 0)

Total = Sum + Surcharge

Dorine

So conclusion, if things are too complex, just split them up in smaller parts

2023-03-16 16-29-51
Paulo Rosário

Hello Keith,

I created a little demo with your case 

This is the logic behind the calculate button, each input has a DecimalVar associated 

if you only wish to use an expression this should work 

Hope it helps! 

Paulo Rosário

UserImage.jpg
keith farwell

This community is amazing.


So, we have children who LOVE the dice game Yahtzee but due to sensory issues will not use pencil and paper for scoring so I have been making one for an iPad/tablet as these mediums work well with the children.  I ran into an issue with how to add bonuses and how to display them properly but from what you guys have shown me has helped immensely, now I can tweak the scoring/bonuses for different fun games!

I am currently trying to figure out how to make numbers of a certain amount show in a particular colour,  once i get that I will clean it up and show you how the final looks if thats ok?

2023-03-16 16-29-51
Paulo Rosário

Can't wait to see it :) 

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.