Jump to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Please help with multiple condition calculation that i want to put into single field.

Featured Replies

Good day maam and sir,

I would like to ask for help about this calculation?if how can I use and apply this one in to one field?

This is for water billing app,

Calculation is :

Previous Reading-Present Reading=Consumption

Consumption =Amount Due

The Consumption is calculated result from below calculations.

But it is depend if the Connection Type is Residential,Commercial or Bulk.

 

If type is Commercial “C”

Case(Consumption>=36;(((((Consumption-15)-10)-10)*21.56)+43.13+945);If(Consumption>=26;((((Consumption-15)-10)*34.5)+600);If(Consumption>=16;(((Consumption-15)*30)+300);If(Consumption>=15;(300);If(Consumption>=10;(300);If(Consumption<=9;Consumption*30;"0"))))))

 

If type is residential “R”

Case(Consumption>=36;(((((Consumption-15)-10)-10)*21.56)+472.5);If(Consumption>=26;((((Consumption-15)-10)*17.25)+300);If(Consumption>=16;(((Consumption-15)*15)+150);If(Consumption>=15;(150);If(Consumption>=10;(150);If(Consumption<=9;Consumption*15;"0"))))))

If Connection Type is Bulk

“B”=Case(Consumption>=1;Consumption*200)

Edited by Mark Pastoril

I don't know where all the numbers come from, but if they are rates, they should be in a separate Rates table so they can be looked up and changed without modifying historical data.

Also, too many parenthesis.  Much of your logic makes no sense, for example in 'Commercial' if consumption is greater or = to 16 is ok, but then you want to know if it's greater or = to 15 and greater or = to 10 have the same result.  Then less than or equal to 9 has a result, but I see no reason for '0'.  Because a zero or negative number is less than 9.

 

Anyway this is easier to read and can be streamlined even further:

Let([
   @C=Consumption;
   @calc=Case(Type="Residential";
                    Case(@C>=36;(@C-15-10-10)*21.56+472.5;
                         @C>=26;(@C-15-10)*17.25+300;
                         @C>=16;(@C-15)*15+150;
                         @C>=10;150;
                         @C*15) 
                         ;
               Type="Commercial";
                    Case(@C>=36;(@C-15-10-10)*21.56+43.13+945;
                         @C>=26;(@C-15-10)*34.5+600;
                         @C>=16;(@C-15)*30+300;
                         @C>=10;300;
                         @C*30)
                         ;

               Type="Bulk";
                     Case(@C>=1;@C*200;0)
              ) //end case
           ];  //end variables
@calc
)

I'll assume all the "-15-10-10" are different rate classes or discounts applied, but like I stated earlier, they should be in a Rates table.  If you were just doing this to see if the calc works, then you can declare each one of those fields in a variable for a cleaner, easier to read calc.

Edited by Steve Martino

I would probably go one step further and put this logic in a script that gets executed as part of the user's workflow when the 'application' is set up or submitted.  The IF... ELSE IF logic will be generally easier to follow and much easier to troubleshoot.

  • Author

Thanks for helping, this solves my problem. I will try to put this in other table.

Create an account or sign in to comment

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.