• Resolved samarmalik71

    (@samarmalik71)


    Hi,
    I belongs to a book publishing copompany. Now, I have to make a form which can show the actual book production cost to the users. In this form, user will enter the number of pages of book, and select the options from the drop-down to see the production cost of the book. The drop-downs are as Book Format (Paperback and Hardcover), Book Size (5X8, 5.5 X 8.5), and book type (B&W or Color).
    If a user enter the number of pages 100 with drop-down selected options (paperback, 5X8, B&W), the result or book cost would be 45% of entered number of pages.

    Please Help

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author codepeople

    (@codepeople)

    Hello @samarmalik71

    Your question describes a unique combination of values (paperback, 5X8, B&W). But you say nothing about other values like 5.5 X 8.5, or Color, or Hardcover.

    Ok, I will try to describe the process with a hypothetical example and the data provided.

    Assuming the fieldname1 is a number field with the number of pages, fieldname2 a dropdown field with the book formats (Paperback and Hardcover), fieldname3 a second dropdown field with the book sizes (5X8, 5.5 X 8.5), and fieldname4 a third dropdown field with the book types (B&W or Color).

    To calculate the price insert a calculated field with the equation:

    (function(){
    if(AND(fieldname2 == 'Paperback', fieldname3 == '5X8', fieldname4 == 'B&W')) return PREC(fieldname1*0.45, 2);
    })()

    The operation PREC(X, Y) rounds the number X with Y decimal places.

    In the previous equation, you should include the other conditions.

    Best regards.

    Thread Starter samarmalik71

    (@samarmalik71)

    Thanks. You are a jem.

    Thread Starter samarmalik71

    (@samarmalik71)

    Hey,
    please help me with an another issue. I prepared this formula with the help of your. But, on the Preview page or webpage, the result of this generala calculation is showing already before entering the value of fieldname2.

    (function(){
    if(AND(fieldname6 == ‘Paperback’, fieldname7 == ‘5″ X 8″‘, fieldname8 == ‘Black & White’)) return PREC(fieldname2*0.8-(fieldname2-100)*0.35, );
    })()

    I am getting, 35 as the value in the result box before entering any value for fieldname2. What I want is to hide 35 from the tab or place 0 instead.
    Here is the link,
    Link

    Plugin Author codepeople

    (@codepeople)

    Hello @samarmalik71

    You can include the fieldname2 into the AND operation of the conditional statement:

    (function(){
    if(AND(fieldname6 == 'Paperback', fieldname7 == '5" X 8"', fieldname8 == 'Black & White', fieldname2|r != '')) return PREC(fieldname2*0.8-(fieldname2-100)*0.35, 2);
    })()

    Best regards.

    Thread Starter samarmalik71

    (@samarmalik71)

    Thank you for time and efforts you are putting to solve the queries of the peopele like me.
    There is a one more question. I am setting up the price range and commission range as well. Like, if the price in fieldname1 is less than 250, the commission would be (60+(fieldname1*0.10)). If, the price is in betweeen 250-500, the commission would be (60+(fieldname1*0.20)). And, if the price is in between 500-1000, the commission would be (60+(fieldname1*0.30)). Is it possible to make a formula for this???

    Plugin Author codepeople

    (@codepeople)

    Hello @samarmalik71

    Yes, of course, you only need to include conditional statements in the equation:

    Assuming the field for the price is the fieldname1, and you want to calculate the commission by using the rules described in your entry. The equation would be similar to:

    (function(){
    if(fieldname1 <= 250) return 60+fieldname1*0.10;
    if(fieldname1 <= 500) return 60+fieldname1*0.20;
    if(fieldname1 <= 1000) return 60+fieldname1*0.30;
    })()

    Please note that your description does not cover the case of a price over 1000.

    Best regards.

    Thread Starter samarmalik71

    (@samarmalik71)

    Thank you for the solution.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Please help with Drop-down Formula’ is closed to new replies.