Alpha Software Mobile Development Tools:   Alpha Anywhere    |   Alpha TransForm subscribe to our YouTube Channel  Follow Us on LinkedIn  Follow Us on Twitter  Follow Us on Facebook

Announcement

Collapse

The Alpha Software Forum Participation Guidelines

The Alpha Software Forum is a free forum created for Alpha Software Developer Community to ask for help, exchange ideas, and share solutions. Alpha Software strives to create an environment where all members of the community can feel safe to participate. In order to ensure the Alpha Software Forum is a place where all feel welcome, forum participants are expected to behave as follows:
  • Be professional in your conduct
  • Be kind to others
  • Be constructive when giving feedback
  • Be open to new ideas and suggestions
  • Stay on topic


Be sure all comments and threads you post are respectful. Posts that contain any of the following content will be considered a violation of your agreement as a member of the Alpha Software Forum Community and will be moderated:
  • Spam.
  • Vulgar language.
  • Quotes from private conversations without permission, including pricing and other sales related discussions.
  • Personal attacks, insults, or subtle put-downs.
  • Harassment, bullying, threatening, mocking, shaming, or deriding anyone.
  • Sexist, racist, homophobic, transphobic, ableist, or otherwise discriminatory jokes and language.
  • Sexually explicit or violent material, links, or language.
  • Pirated, hacked, or copyright-infringing material.
  • Encouraging of others to engage in the above behaviors.


If a thread or post is found to contain any of the content outlined above, a moderator may choose to take one of the following actions:
  • Remove the Post or Thread - the content is removed from the forum.
  • Place the User in Moderation - all posts and new threads must be approved by a moderator before they are posted.
  • Temporarily Ban the User - user is banned from forum for a period of time.
  • Permanently Ban the User - user is permanently banned from the forum.


Moderators may also rename posts and threads if they are too generic or do not property reflect the content.

Moderators may move threads if they have been posted in the incorrect forum.

Threads/Posts questioning specific moderator decisions or actions (such as "why was a user banned?") are not allowed and will be removed.

The owners of Alpha Software Corporation (Forum Owner) reserve the right to remove, edit, move, or close any thread for any reason; or ban any forum member without notice, reason, or explanation.

Community members are encouraged to click the "Report Post" icon in the lower left of a given post if they feel the post is in violation of the rules. This will alert the Moderators to take a look.

Alpha Software Corporation may amend the guidelines from time to time and may also vary the procedures it sets out where appropriate in a particular case. Your agreement to comply with the guidelines will be deemed agreement to any changes to it.



Bonus TIPS for Successful Posting

Try a Search First
It is highly recommended that a Search be done on your topic before posting, as many questions have been answered in prior posts. As with any search engine, the shorter the search term, the more "hits" will be returned, but the more specific the search term is, the greater the relevance of those "hits". Searching for "table" might well return every message on the board while "tablesum" would greatly restrict the number of messages returned.

When you do post
First, make sure you are posting your question in the correct forum. For example, if you post an issue regarding Desktop applications on the Mobile & Browser Applications board , not only will your question not be seen by the appropriate audience, it may also be removed or relocated.

The more detail you provide about your problem or question, the more likely someone is to understand your request and be able to help. A sample database with a minimum of records (and its support files, zipped together) will make it much easier to diagnose issues with your application. Screen shots of error messages are especially helpful.

When explaining how to reproduce your problem, please be as detailed as possible. Describe every step, click-by-click and keypress-by-keypress. Otherwise when others try to duplicate your problem, they may do something slightly different and end up with different results.

A note about attachments
You may only attach one file to each message. Attachment file size is limited to 2MB. If you need to include several files, you may do so by zipping them into a single archive.

If you forgot to attach your files to your post, please do NOT create a new thread. Instead, reply to your original message and attach the file there.

When attaching screen shots, it is best to attach an image file (.BMP, .JPG, .GIF, .PNG, etc.) or a zip file of several images, as opposed to a Word document containing the screen shots. Because Word documents are prone to viruses, many message board users will not open your Word file, therefore limiting their ability to help you.

Similarly, if you are uploading a zipped archive, you should simply create a .ZIP file and not a self-extracting .EXE as many users will not run your EXE file.
See more
See less

Converting Excel Formula

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Converting Excel Formula

    I've been trying to figure this out all day, just a headache to show for it..

    The following is an Excel formula which calculates total discount % on a purchase amount :

    =IF(Purchaseamount<150000,0%,
    IF(Purchaseamount<200000,15000/Purchaseamount-10%,
    IF(Purchaseamount<250000,25000/Purchaseamount-15%,
    IF(Purchaseamount<500000,62500/Purchaseamount-30%,
    IF(Purchaseamount<1000000,75000/Purchaseamount-32.5%,-25%)))))

    this works on a sliding scale - 0% for less than $150,000, 10% for the next $50,000, etc (expressed as units of a thousand below)

    < 150 0%
    150-200 10.00%
    200-250 15.00%
    250-500 30.00%
    500-1,000 32.50%
    > 1,000 25.00%

    the total discount for $300,000 for example would be 9.17%,

    But I can't make it work in a calc field


    Any help to put me out of my misery would be appreciated !

    thx

    Steve

    #2
    Re: Converting Excel Formula

    Interesting question.

    Others may have simpler or more elegant solutions.

    Here's a brute force approach that is largely self-explanatory. Holler if you have questions.

    Comment


      #3
      Re: Converting Excel Formula

      Code:
      FUNCTION DISC AS N (PurchaseAmount AS N )
      	dim dm as n=0
      	dim pct as n=0
      select
      	case PurchaseAmount<150000
      	    dm=0  
      	    pct=0
      	case PurchaseAmount<=200000
      		dm=15000
      		pct=.1	
      	case PurchaseAmount<=250000
      		dm=25000
      		pct=.15	
      	case PurchaseAmount<=500000
      		dm=62500
      		pct=.3			    
          case  PurchaseAmount<1000000
      	    dm=75000
      	    dm=.325		
          case  PurchaseAmount>=1000000
      	    dm=0
      	    pct=.25
      end select
      DISC=dm/PurchaseAmount-pct	
      END FUNCTION
      dim purchaseamount as n
      purchaseamount=149000
      ?disc(purchaseamount)
      = 0
      purchaseamount=150000
      ?disc(purchaseamount)
      = 0

      purchaseamount=151000
      ?disc(purchaseamount)
      = -0.000662251655629

      purchaseamount=200000
      ?disc(purchaseamount)
      = -0.025
      purchaseamount=300000
      ?disc(purchaseamount)
      = -0.091666666666667

      purchaseamount=500000
      ?disc(purchaseamount)
      = -0.175

      purchaseamount=1000000
      ?disc(purchaseamount)
      = -0.25
      purchaseamount=2000000
      ?disc(purchaseamount)
      = -0.25
      Last edited by G Gabriel; 05-28-2011, 12:55 PM.

      Comment


        #4
        Re: Converting Excel Formula

        Thanks, G.

        I knew there had to be a simpler way.

        Your post caused me to test other values. I discovered an error in my code. The corrected function is
        attached.

        Do you get the same as these?

        Code:
        [FONT="Courier New"]?disc(500000)
        = 17.5
        
        ?disc(600000)
        = 20
        
        ?disc(2000000)
        = 25
        
        ?disc(300000)
        = 9.17[/FONT]

        Comment


          #5
          Re: Converting Excel Formula

          8am on a New Zealand sunday morning and two solutions waiting for me !

          Will get onto this..

          Many thanks to you both..

          Comment


            #6
            Re: Converting Excel Formula

            I'm embarrassed to say this, but I have no idea of what to do with Function code !

            Can somebody give me a pointer..?

            Thanks..

            Comment


              #7
              Re: Converting Excel Formula

              Tom:
              Originally posted by Tom Cone Jr View Post
              Do you get the same as these?
              Yes.
              Here are the results I am getting:
              Code:
              ?disc(500000)
              = -0.175
              
              ?disc(600000)
              = 5.41667e-007
              
              ?disc(2000000)
              = -0.25
              
              ?disc(300000)
              = -0.091666666666667
              As you can see all match yours except (seemingly) 600,000 does not match.
              In reality, it does.
              As you can see, mine produced an exp number, yours didn't.
              Hmm...!
              I am assuming you are running v10. I am doing this in v8.
              Why is the difference?
              Because we are divining very large numbers, we have just entered the floating point arena.
              I could finagle my function to avoid that... BUT.. this seems to be only necessary if you are not using v10...
              Can you test in v8?
              And can you test other values, crazy ones like 75000/999999.99 in v10 and see if you get exp numbers?
              Thanks
              Last edited by G Gabriel; 05-28-2011, 07:38 PM.

              Comment


                #8
                Re: Converting Excel Formula

                Steve:
                To use the function, simply:
                1-Copy the function from the message board
                2-In the code tab of your alpha, click New->function
                3-In the Function Name, put DISC
                4-Uncheck the box Underneath and click OK
                5-Paste then save the function
                6-Close the window and refresh the code tab (Click Refresh at the menu bar)
                Now you have a function called DISC() that you could use just like any other alpha function

                Comment


                  #9
                  Re: Converting Excel Formula

                  Oh ! - that easy..

                  Thanks G !

                  Comment


                    #10
                    Re: Converting Excel Formula

                    Steve:
                    Please take note:
                    Tom pointed out a glitch in my function.
                    It's a dumb typo (from copy/paste).
                    The corrected function should be:
                    Code:
                    FUNCTION DISC AS N (PurchaseAmount AS N )
                    	dim dm as n=0
                    	dim pct as n=0
                    select
                    	case PurchaseAmount<150000
                    	    dm=0  
                    	    pct=0
                    	case PurchaseAmount<=200000
                    		dm=15000
                    		pct=.1	
                    	case PurchaseAmount<=250000
                    		dm=25000
                    		pct=.15	
                    	case PurchaseAmount<=500000
                    		dm=62500
                    		pct=.3			    
                        case  PurchaseAmount<1000000
                    	    dm=75000
                    	    [B][SIZE="4"][COLOR="red"]pct[/COLOR][/SIZE][/B]=.325		
                        case  PurchaseAmount>=1000000
                    	    dm=0
                    	    pct=.25
                    end select
                    DISC=dm/PurchaseAmount-pct	
                    END FUNCTION

                    Comment

                    Working...
                    X