# How to use If and If else statement or switch case in bubble

am working on a payroll calculator where i have to calculate Payroll of every employee. i am having serious issues with calculating a Payee tax. for eg. If and employee salary is \$500 the tax is 0, else if tax is greater than \$500 but less than \$1100 then tax is 15%. if tax is greater than \$1100 but less than \$1600 the taxt is 20% and son on. is there a plugin i should use of is there a way to get it done. olease i need this help

1 Like

Iâ€™m sure there are multiple ways to accomplish this task, but If you are saving the tax to the database, then you can use the â€śonly whenâ€ť functionality in the workflow to multiply the salary by the appropriate rate. So, you might have a workflow step that saves the employeeâ€™s salary, and then the next step would calculate the tax rate by referencing the saved salary and multiplying it by, for example, 15% only when the salary is between \$500 and \$1100. You would have multiple workflow steps to account for each rate, and the appropriate step would be completed because of the â€śonly whenâ€ť conditions.

Do you think that would work for you? Hope it helps.

Bestâ€¦
Mike

3 Likes

Mic it your explanation is very clear, let me try it and seeâ€¦i will let you know. is there any way you could help with a pictorial explanation

Sure thingâ€¦ here are some screenshots that show the idea I described aboveâ€¦ check them out and see if they make sense to you. Again, Iâ€™m sure there are other ways to do what you want to do here, but this is one way that would work.

Bestâ€¦
Mike

1 Like

I have a feeling that this solution will work well for me. However I have tried it, no data is displaying. it might be that my syntax is incorrect. Is there a way I can access a video link, Please?

It looks like youâ€™re on the right track, so Iâ€™m not sure a video would add much value here. The bottom part of the â€śonly whenâ€ť condition is cut off in your screenshotâ€¦ can you show the rest of it? And maybe grab a screenshot of the next workflow step, too?

You say no data are displaying? Do you mean no data are displaying on a page or no data are being saved to the database?

Bestâ€¦
Mike

The page i created to display the saved data from the database is not displaying the payee tax. Also no data is saved to the database.

Oh, waitâ€¦ do you have a form on which you are trying to calculate the Payee Tax in real time when the user enters their basic salary? In other words, the user enters the information, the Payee Tax is calculated for them and shown on the screen, and then the user clicks a button to save all of that information?

exactly so sir. that is exactly what i am trying to accomplish here!

Ah, okayâ€¦ sorry about that. If that is the case, then I sent you down the wrong path with the workflow steps. I think what you really need is to do the calculations on the Payee Tax element itself by using the elementâ€™s Conditional tab as follows:

Want to give that a shot and see if it works for you?

Bestâ€¦
Mike

am going to implement it now, and will let you know the outcome as soon as i am done.

Please see the conditions i used under the tax, but still am having issue displaying the data

I assume the Gross Salary field on the form is Basic Salary?