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

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?

No please!
The Gross Salary is the sum of the total income, which comprises of the medical allowance, housing allowance, sport allowance, Overtime and the likes. the Basic Salary However, is a single field, what you are paid,separate from other allowances.

You might wanna check out this post. Its’ available in the bdk utilities plugin

2 Likes