Alpha Video Training
Results 1 to 14 of 14

Thread: Formula Puzzle

  1. #1
    Bill Feldhaus
    Guest

    Default Formula Puzzle

    Hello, I work in a hospital and I have an Excel spreadsheet created for insulin drip calculations. I am a novice with Alpha 5 yet and I am having trouble converting the Excel calculations to work in Alpha. I will include what I have so far:
    Spreadsheet example:

    Accu- Glucose Basal Basal Proport. Tot Action
    Check Rate Rate
    Sequ. #
    1 490 0 0 9.75 8.0
    2 400 0.3 0.3 7.5 7.8
    3 300 0.5 0.5 5 5.5
    4 248 0.7 0.7 3.7 4.4
    5 95 0.5 0.5 -0.125 0.4
    6 110 0.5 0.5 0.25 0.8
    7 80 0.2 0.2 -0.5 0.0
    8 60 -0.8 0 -1 0.0 give 1amp D50
    9 100 0 0 0 0.0
    10 105 0 0 0.125 0.1
    11 140 0.1 0.1 1 1.1
    12 0.1 0.1 0 0.1
    13 0.1 0.1 0 0.1
    14 0.1 0.1 0 0.1
    15 0.1 0.1 0 0.1
    16 0.1 0.1 0 0.1
    Etc.
    All values are calculated off what the nurse types in the glucose column. Rows 12 and on have no data typed in therefore the values that you see.
    Now for the formulas that make the spread sheet work:

    Proportional Rate = IF(B2>0,0.025*(B2-100),0)

    Total Rate = IF(D2+E2>8,8,IF(D2+E20,IF(B3>349,D2+0.3,
    IF(B3>199,D2+0.2,
    IF(B3>129,D2+0.1,
    IF(B3>99,D2,
    IF(B3>89,D2-0.2,
    IF(B3>79,D2-0.3,
    IF(B3>68,D2-0.5,C2-1))))))),D2)

    Basal 2 = IF(C20,0.025*(GLUCOSE-100),0)

    Total Rate = IF(BASAL2+RATE>8,8,IF
    (BASAL2+RATE0,IF(GLUCOSE>349,BASAL2+0.3,IF(GLUCOSE>199,BASAL2+0.2,

    IF(GLUCOSE>129,BASAL2+0.1,IF(GLUCOSE>99,BASAL2,IF(GLUCOSE>89,BASAL2-0.2,

    IF(GLUCOSE>79,BASAL2-0.3,IF(GLUCOSE>68,BASAL2-0.5,BASAL-1))))))),BASAL2))

    I know this looks very complicated but if someone can print it off and look at it I'd appreciate it.
    I added the first part of this last formula recently to try and make it work: IF(GLUC_ID=0,0 but it still does not function.
    Thank you.
    Bill





  2. #2
    Bill Feldhaus
    Guest

    Default RE: Formula Puzzle

    What a mess that message became. The columns for the spreadsheet were smashed together. The first row of data should read like this:
    Accucheck Sequence # = 1
    Glucose = 490
    Basal = 0
    Basal = 0
    Proportional = 9.75
    Total Inuslin Rate (Units/hr) = 8.0
    Action = (nothing)
    Hope this helps.
    Thanks.

  3. #3
    "Certified" Alphaholic Stan Mathews's Avatar
    Real Name
    Stan Mathews
    Join Date
    Apr 2000
    Location
    Bowling Green, KY
    Posts
    25,119

    Default RE: Formula Puzzle

    Sort of hard to read due to the "unformatting" caused by cut and paste.

    Can you attach a small sample of the spreadsheet?

  4. #4
    Bill Feldhaus
    Guest

    Default RE: Formula Puzzle

    Attached is the excel sheet with typical values filled in.

    Thanks for any ideas/help.

  5. #5
    Member
    Real Name
    Robin Sculthorpe
    Join Date
    Mar 2001
    Posts
    220

    Default RE: Formula Puzzle

    What exactly is failing about the basal formula? Is it that the first basal calculation doesn't work out to be zero, or is it that all the calculated values are incorrect? What exactly does the alpha 5 field glucose_ID represent on the XCEL spreadsheet?

    I am a pharmacist and will try to help, but I'm not how everything in your alpha expression relates to what'
    s on the spreadsheet.

    Kind regards,
    Robin Sculthorpe

  6. #6
    "Certified" Alphaholic Charles Hoens's Avatar
    Real Name
    Charles Hoens
    Join Date
    Sep 2000
    Location
    Princeton, NJ
    Posts
    1,170

    Default RE: Formula Puzzle

    Bill,

    It looks as if you've nested too many "If"'s together for A5. Excel is more tolerant. I believe the limit for A5 is 8 or 9, so in order for this to work, you'll have to break it down.

    Charlie

  7. #7
    Member
    Real Name
    Robin Sculthorpe
    Join Date
    Mar 2001
    Posts
    220

    Default RE: Formula Puzzle

    Hi,

    If this is your expression,

    BASAL = IF(GLUC_ID=0,0,IF(GLUCOSE>0,IF(GLUCOSE>349,BASAL2+0.3,IF(GLUCOSE>199,BASAL2+0.2,

    IF(GLUCOSE>129,BASAL2+0.1,IF(GLUCOSE>99,BASAL2,IF(GLUCOSE>89,BASAL2-0.2,

    IF(GLUCOSE>79,BASAL2-0.3,IF(GLUCOSE>68,BASAL2-0.5,BASAL-1))))))),BASAL2))


    Then you are trying to calculate a value for Basal and you
    also have Basal as a field in the calculation. They would have to have different names, i.e. new_basal and prev_basal or something like that.

    Robin Sculthorpe

  8. #8
    Paul Miller
    Guest

    Default RE: Formula Puzzle

    Hi Robin,
    Yes, I have two basal fields (Basal and Basal2). I am trying to copy a spreadsheet created by one of our physicians. He wanted to keep the information in a database for further evaluation. I will include a copy of the Excel spreadsheet we use with common glucose values entered. Only the glucose number is plugged in by the nurse. The other cells in the spreadsheet are calculated from the glucose number and depend on how high that entered value is.
    Here are the fields I have created:
    1. Glucose (the number entered by the nurse)

    2. Basal - a calculated number field which must always have a value of zero for the first record and then follow the nested "IF" statement:
    IF(GLUC_ID=0,0,IF(GLUCOSE>0,IF(GLUCOSE>349,PREVIOUS('BASAL2')+0.3,IF(GLUCOSE>199,PREVIOUS('BASAL2')+0.2,IF(GLUCOSE>129,PREVIOUS('BASAL2')+0.1,IF(GLUCOSE>99,PREVIOUS('BASAL2'),IF(GLUCOSE>89,PREVIOUS('BASAL2')-0.2,IF(GLUCOSE>79,PREVIOUS('BASAL2')-0.3,IF(GLUCOSE>68,PREVIOUS('BASAL2')-0.5,BASAL-1))))))),PREVIOUS('BASAL2')))

    3. Basal2 - another calculated number field:
    IF(BASAL0,0.025*(GLUCOSE-100),0)

    5. Total Rate - another calculated number field:
    IF(BASAL2+RATE>8,8,IF(BASAL2+RATE0,IF(B3>349,D2+0.3,
    IF(B3>199,D2+0.2,
    IF(B3>129,D2+0.1,
    IF(B3>99,D2,
    IF(B3>89,D2-0.2,
    IF(B3>79,D2-0.3,
    IF(B3>68,D2-0.5,C2-1))))))),D2)
    Basal2:
    =IF(C20,0.025*(B2-100),0)
    Total Rate:
    =IF(D2+E2>8,8,IF(D2+E2

  9. #9
    Bo Vandenberg
    Guest

    Default RE: Formula Puzzle

    This is a proper puzzle that includes a fair whack of reverse engineering to discover the formulas used. As an exercise I took apart the first cel of the Spreadsheat.

    There are actually 2 variables that are recursive. In other words Glucose determines a modification to the value of Basal1 based on the previous values of Basal2 unless Glucose is between 0 and 68.

    If Glucose >349 then Basal1 = Prevbasal2 + 0.3
    If Glucose >199 then Basal1 = Prevbasal2 + 0.2
    IF Glucose >129 then Basal1 = Prevbasal2 + 0.1
    IF Glucose >99 then Basal1 = Prevbasal2
    If Glucose >89 then Basal1 = Prevbasal2 - 0.2
    If Glucose >79 then Basal1 = Prevbasal2 - 0.3
    If Glucose >68 then Basal1 = Prevbasal2 - 0.5
    If Glucose is not greater than 68 then Basal1 = Prevbasal1 -1
    if Glucose

  10. #10
    Bo Vandenberg
    Guest

    Default RE: Formula Puzzle

    These might be better as a numeric value prompting a selection from an array.

    Current Basal1 = PrevBasal2 plus a selection from {-0.5,-0.3,-0.2,0,0.1,0.2,0.3} for all glucose values greater than 68. Then deal with values not greater than 68 seperately.

    I don't know how it would be done but it would be much neater than nested if statements.

  11. #11
    Thomas Henkel
    Guest

    Default RE: Formula Puzzle

    With that IF statement, a value over 349 would have the same number as all the others. I think you need to REVERSE the IF so that the lower values get evaluated first, then the higher values. This way, the IF will bail out at the first occurance of the number, if it is a low number, MAYBE the answer will be correct, otherwise, you can be sure that the answer will be wrong.

    Tom

  12. #12
    Thomas Henkel
    Guest

    Default RE: Formula Puzzle

    an Example:

    Basal = IF(B3>0,IF(B3>349,D2+0.3,
    IF(B3>199,D2+0.2,
    IF(B3>129,D2+0.1,
    IF(B3>99,D2,
    IF(B3>89,D2-0.2,
    IF(B3>79,D2-0.3,
    IF(B3>68,D2-0.5,C2-1))))))),D2)

    if B3 > 349, then the 1st if will be true, AND ALL 6 of the others will also be true!!! so your answer will be D2-.05.

    Switch it around

    Basal = IF(b3>0,IF(B3>68,D2-.05,
    IF(B3>79,D2-0.3,
    IF(B3>89,D2-0.2,
    IF(B3>99,D2,
    IF(B3>129,D2+0.1,
    IF(B3>199,D2+0.2,
    IF(B3>349,D2+0.3,C2-1))))))),D2)


    Tom

  13. #13
    Bo Vandenberg
    Guest

    Default RE: Formula Puzzle

    My If statement is a mess! I was just so happy I worked through what all the elements meant that I didn't even attempt to make real code :).

    I still think there has to a better way than the nested If statements though.

    BO

  14. #14
    Thomas Henkel
    Guest

    Default RE: Formula Puzzle

    Cut and paste, it's a wonderful thing.

    It really is remarkable how helping your child with grade school math will do to help clear things up.

    Tom

Similar Threads

  1. string puzzle
    By Chris.Tanti in forum Alpha Five Version 6
    Replies: 4
    Last Post: 03-14-2005, 07:43 AM
  2. A New Year puzzle...
    By Paul H in forum Alpha Four Versions 7 and 8
    Replies: 1
    Last Post: 02-17-2005, 12:49 AM
  3. Scripting Puzzle
    By Tim Madison in forum Alpha Five Version 5
    Replies: 4
    Last Post: 05-18-2004, 03:27 PM
  4. Formula Puzzle Continued
    By Bill Feldhaus in forum Alpha Five Version 5
    Replies: 12
    Last Post: 10-30-2003, 08:43 AM
  5. Puzzle 2
    By Tom Cone Jr in forum Alpha Five Version 4
    Replies: 9
    Last Post: 04-16-2001, 07:36 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •