Jump to content
UBot Underground

Recommended Posts

I have a table with 50 rows (a screencap of part of it is below).  I have another csv file that states how many visits a writer averages on his/her posts.  Basically I need to set a variable called #rate that will correspond to the range that the person falls under.  For instance, if the person averages 200 visits per post, then #rate will equal $1.50.  I need it to loop through a csv of users to calculate each one and add them all to a new list.  I'm not sure how to go about it without manually setting each range as a separate if statement, and I feel like there must be a smarter and easier way than that.  Does anyone have any ideas?

 

http://i39.tinypic.com/mj766x.jpg

Edited by katelynnm
Link to post
Share on other sites

another solution would be creating csv table with scores and values just like you have on the picture.

load csv to table and compare each user's score with 1st column values in loop using logic: score is bigger than cell A (row X column 1) but less than cell B (row X+1 column 1) if true - take value from column 2 row A, increment X each time

Link to post
Share on other sites

I think this should work for you.

 

The idea is that the range is not important but the lowest qualifying visit count for a specific rate is. For example it does not matter if there were 1500 visits or 1599, it would still be the same rate.

 

You can use the javascript math floor function, it rounds down to the nearest integer. 1.5 -> 1, 7.43 -> 7. 

 

First it makes the average visitor into a decimal by dividing by 100. 345 will equal 3.45. Than the eval will round it down to 3 which get multiplied by 100 again to get the lower range. Which you can then compare with the values from the compensation chart.

 

I used a not contains, but in this case a comparison will be better, just make sure you are comparing a number to a number, remove the plus sign when comparing. 

 

I hope this made sense.

set(#decimal, $divide(#averageVisits, 100), "Global")
set(#value, $multiply($eval("Math.floor({#decimal})"), 100), "Global")
set(#value counter, 0, "Global")
loop while($not($contains($table cell(&table, #value counter, 0), #value))) {
    increment(#value counter)
}
set(#rate, $table cell(&table, #value counter, 1), "Global")
  • Like 1
Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...