IF conditon with amount wont work

The bot always goes “Else”, how do i get it to go “then” if "Belopp is less then 1500,00?

1 Like

@Doktorgud What is the Type of Belopp, Make sure it is a Double Type or an Integer Type for Comparing Numericals and you cannot use Comma’s in 1500,00, it can be just 150000.

I am not able to replicate the issue using the same data types and values. Even when comparing an int to float the evaluation seems to work fine.

Where are you assigning Belopp and how did you determine that it is always going to Else? Did you check the PitlaneOK value or did you put a Log Message inside of the Then and Else block to see which route it is taking.

I recommend debugging using the Slow Step feature to see whats going on. The variable values will be displayed in the Locals pane on the left-hand side of the screen. For more information see https://docs.uipath.com/studio/docs/debugging-actions

@Doktorgud do not use comma in the amount

Mention the condition like this
Belopp < Convert.ToInt32((“1500,00”).ToString.Replace(“,”,””))

And also make sure that the value of Belopp value is actually less than 150000

To validate that value use a write line activity before to this IF condition and mention like this
Belopp.ToString so that we could know the value

Cheers @Doktorgud

1 Like

I assume that belopp is a correct variable of Number Datatype like Int, Double…
the comma of the 1500,00 should be interpretated as the decimal seperator, so the value is 1500 and not 150000

In some locals (e.g Germany) the decimal separator is a comma. From technical viewpoint the decimal seperator is a dot (that also why you get this Validation error)

But the compair condition you have under control and you can change to 1500 or 1500.00

for a further investigation of the scenario it is recommended to debug, breakpoint halting and explore it within the watch panel

To get the get text to work i need to use String, i get “608,00” i need to tell the bot to go “then” in the IF.

it looks to me on first look that:
Belopp is of string containing the comma as decimal seperator, as it is returned from a get text

So string requires to get converted into an int or double (here the comma case is to take into account)
then int (or double) can be compared with int (or double) and the if case should work as expected

Let us know if you need more help on converting string to int/double for your case

@Doktorgud, If its just matter of IF statement then try following statement in IF condition.

Convert.ToDouble(Belopp) < Convert.ToDouble(“1500,00”)

It should work. Cheers.

1 Like

what did i do wrong?

@Doktorgud, hhhmmm…I can see blank space in Belopp value “4 798,65”. Is this correct? If so you may want to use Assign Activity just before IF condition with following values.

Belopp = Belopp.Replace(" ", “”)


1 Like

Damn it, been stuck on this all day, not sure i can think anymore.

How do i trim the comma and remove everything after comma then?
Tell me what to do?

Drink wine? :stuck_out_tongue:

@Doktorgud Please Follow what @Bhavik_Solanki suggested :sweat_smile:

1 Like

Sorry you reply was so fast, missed it, BRB gonna try it! thanks!!!

@Doktorgud But why does your Belopp variable have a Space in it :thinking:

So need an assign to remove that as well?

@Doktorgud, Just remove blank space, no need to remove comma.

@Doktorgud You can use An Assign Activity and Update belopp variable , It’s Better Actually.
Also you can use that Expression Directly as well in the if condition.

1 Like

Find demo XAML showcasing on how to handle
Doktorgud.xaml (6.8 KB)

ensure that in your implementation System.Globalization is imported
handling a comma as decimal seperator can be done as following:
nfi = new NumberFormatInfo()
nfi.NumberDecimalSeparator = “,”

Parsing the string to double: dblBelopp = Double.Parse(Belopp,nfi) / Belopp is of string and has value 602,08 for example

or with variation for containing space: Double.Parse(Belopp.Replace(" “,”"),nfi)

Condition from if else: dblBelopp < 1500.00 take a note on the dot, so it looks if dblBelopp is less then 1500

1 Like

Im doing something wrong with the assign?