Info Retrieval term frequency (td.idf) calculation problem

anyone who's done any IR work like search engines should be familiar with the td.idf forumula i've tried to use. problem is, i've got it wrong somewhere. The results come back the same for each document and sometimes i get negative results.
<%@ page language="java" contentType="text/html"
    errorPage="errorpage.jsp" import="java.util.*,java.sql.*,java.lang.Math.*" %>
<%
    String strUser= "cooks";
    String strPass= "d885764c";
    String strConnectURL= ("jdbc:mysql://localhost/cooks");
    Class.forName("com.mysql.jdbc.Driver");
    Connection conn = DriverManager.getConnection(strConnectURL,strUser,strPass);
    Statement stmt = conn.createStatement();
    ResultSet rs;
    String sql;
    String searchTerm = request.getParameter("search");
    ArrayList score = new ArrayList();
    ArrayList product = new ArrayList();     
    final int recall = 20;
    ArrayList splitTerms = new ArrayList();
    StringTokenizer st = new StringTokenizer(searchTerm);
    while(st.hasMoreTokens())
        splitTerms.add(st.nextToken());
    String tempSearchTerm = ""+splitTerms.get(0);
    if(splitTerms.size() == 1 && tempSearchTerm.length() == 5)
        try
            int productCode = Integer.parseInt(""+splitTerms.get(0));
            sql = "SELECT id FROM product WHERE id = "+productCode+";";
            rs = stmt.executeQuery(sql);
            while(rs.next())
                    response.sendRedirect("product.jsp?productID="+rs.getString(1));
        catch(NumberFormatException e){}
    ArrayList docBaseN = new ArrayList();
    ArrayList docBaseD = new ArrayList();
    ArrayList docBaseNid = new ArrayList();
    ArrayList docBaseDid = new ArrayList();
    // ------------------------ Get items that have part of searchTerm in name -------------------------- //
    sql = "SELECT id, name FROM product WHERE UPPER(name) LIKE UPPER('%";
    for(int i=0; i<splitTerms.size(); i++)
        sql += splitTerms.get(i) + "%')";
        if(i < splitTerms.size()-1)
            sql += " OR description LIKE UPPER('%";
    sql += ";";
    rs = stmt.executeQuery(sql);
    while(rs.next())
        docBaseNid.add(rs.getInt(1));
        docBaseN.add(rs.getString(2));
    out.print("<br><hr><strong>GET RELEVANT NAMED ITEMS: </strong>\t"+sql+"<br>");
    // --------------------- Get items that have part of searchTerm in description ---------------------- //
    sql = "SELECT id, description FROM product WHERE UPPER(description) LIKE UPPER('%";
    for(int i=0; i<splitTerms.size(); i++)
        sql += splitTerms.get(i) + "%')";
        if(i < splitTerms.size()-1)
            sql += " OR description LIKE UPPER('%";
    sql += ";";
    rs = stmt.executeQuery(sql);
    while(rs.next())
        docBaseDid.add(rs.getInt(1));
        docBaseD.add(rs.getString(2));
    out.print("<strong>GET RELEVANT DESCRIBED ITEMS: </strong>\t"+sql+"<hr>");
    rs.close();
    stmt.close();
    conn.close();
    // ---------------------------------- Calculate TD.IDF for n ---------------------------------------- //
    double TDn = 0.0;
    double[] TDIDFn = new double[docBaseN.size()];
    double Nn = 0;
    int sumN = 0;
    for(int i=0; i<docBaseN.size(); i++)
        st = new StringTokenizer(""+docBaseN.get(i));
        sumN += st.countTokens();
        while(st.hasMoreTokens())
            String baseTerm = st.nextToken();
            for(int j=0; j<splitTerms.size(); j++)
                session.setAttribute("debug",136);
                if(baseTerm.equalsIgnoreCase(""+splitTerms.get(j)))
                    Nn ++;
    try
        out.print("Nn = "+Nn+"\tsumN = "+sumN+" ");
        TDn = Nn/sumN;
        out.print(TDn);
    catch(Exception e)
        TDn = 0;
    double[] IDFn = new double[docBaseN.size()];
    int Dn = docBaseN.size();
    int[] docsWithTn = new int[docBaseN.size()];
    for(int i=0; i<docBaseN.size(); i++)
        IDFn[i] = 0.00;
        TDIDFn[i] = 0.00;
        docsWithTn[i] = 0;
    for(int i=0; i<splitTerms.size(); i++)
        for(int j=0; j<docBaseN.size(); j++)
            st = new StringTokenizer(""+docBaseN.get(j));
            out.print("tokens = "+st.countTokens()+"<p>");
            compare:
                while(st.hasMoreTokens())
                    String tempStrA = ""+st.nextToken();
                    String tempStrB = ""+splitTerms.get(i);
                    out.print(tempStrA+" "+tempStrB+"<br>");
                    if(tempStrA.equalsIgnoreCase(tempStrB))
                        out.print("found match <p>");
                        docsWithTn[j] ++;
                        out.print(docsWithTn[j]+"<p>");
                        break compare;
    for(int i=0; i<docsWithTn.length; i++)
        try
            IDFn[i] += 1-(Math.log(Dn/docsWithTn));
out.print("Dn = "+Dn+"<br>");
out.print("docsWithTn["+i+"] = "+docsWithTn[i]+"<br>");
out.print("IDFn["+i+"] = "+IDFn[i]+"<br>");
catch(Exception e)
IDFn[i] = 0;
out.print("IDFn["+i+"] = "+IDFn[i]+"<br>");
for(int i=0; i<IDFn.length; i++)
TDIDFn[i] += TDn*(IDFn[i]);
out.print("<br><strong>id = "+docBaseNid.get(i)+" \tTDIDFn["+i+"] = "+TDIDFn[i]+"</strong>");
out.print("<p>");
// ---------------------------------- Calculate TD.IDF for d ---------------------------------------- //
double TDd = 0.0;
double[] TDIDFd = new double[docBaseD.size()];
double Nd = 0;
int sumD = 0;
for(int i=0; i<docBaseD.size(); i++)
st = new StringTokenizer(""+docBaseD.get(i));
sumD += st.countTokens();
while(st.hasMoreTokens())
String baseTerm = st.nextToken();
for(int j=0; j<splitTerms.size(); j++)
if(baseTerm.equalsIgnoreCase(""+splitTerms.get(j)))
Nd ++;
try
out.print("Nd = "+Nd+"\tsumD = "+sumD+" ");
TDd = Nd/sumD;
out.print(TDd);
catch(Exception e)
TDd = 0;
double[] IDFd = new double[docBaseD.size()];
int Dd = docBaseD.size();
int[] docsWithTd = new int[docBaseD.size()];
for(int i=0; i<docBaseD.size(); i++)
IDFd[i] = 0.00;
TDIDFd[i] = 0.00;
docsWithTd[i] = 0;
for(int i=0; i<splitTerms.size(); i++)
for(int j=0; j<docBaseD.size(); j++)
st = new StringTokenizer(""+docBaseD.get(j));
out.print("tokens = "+st.countTokens()+"<p>");
compare:
while(st.hasMoreTokens())
String tempStrA = ""+st.nextToken();
String tempStrB = ""+splitTerms.get(i);
out.print(tempStrA+" "+tempStrB+"<br>");
if(tempStrA.equalsIgnoreCase(tempStrB))
out.print("found match <p>");
docsWithTd[j] ++;
out.print(docsWithTd[j]+"<p>");
break compare;
for(int i=0; i<docsWithTd.length; i++)
try
IDFd[i] += 1-(Math.log(Dd/docsWithTd[i]));
out.print("Dd = "+Dd+"<br>");
out.print("docsWithTd["+i+"] = "+docsWithTd[i]+"<br>");
out.print("IDFd["+i+"] = "+IDFd[i]+"<br>");
catch(Exception e)
IDFd[i] = 0;
out.print("IDFd["+i+"] = "+IDFd[i]+"<br>");
for(int i=0; i<IDFd.length; i++)
TDIDFd[i] += TDd*(IDFd[i]);
out.print("<br><strong>id = "+docBaseDid.get(i)+" \tTDIDFd["+i+"] = "+TDIDFd[i]+"</strong>");
%>

ricky171
Welcome to the forum. Please don't post in old threads that are long dead. When you have a question, please start a topic of your own. Feel free to provide a link to an old thread if relevant.
Also, please don't solicit off-forum communication by email. This not only goes against the spirit of the forum, which is to share problems and their solutions, but will also fetch you plenty of spam, but rarely any help.
I'm locking this thread now. It's more than 4½ years old.
Also blocking both the posts soliciting off-forum communication.
db

Similar Messages

  • Term frequency (tf idf)

    I need some help on term frequency (how to store the data)
    I have severals document that will be parsed and tokenized for words (also apply stoword and stemmer).
    The word are then stored in the database (where the word is the primary key).
    given the equation
    let
    td = # of time the term t appear in document d,
    md = maximum absolute term freq by aany term in d
    then tf = td/md
    my problem is this.
    Suppose Document 1 contains the word "Java" 500 times(td) and the max is 1000(md) // some other word has 1000 freq.
    and suppose in Document 2, "java" occus 200 times(td) and md is 500.
    tf for document 1 = .5
    and tf for document 2 = .4
    however..I wanted to calculate the weight of the term for all frequencies
    I don't think i can just add 200 to the counter and divided by the highest md
    i'm a lost here.

    ricky171
    Welcome to the forum. Please don't post in old threads that are long dead. When you have a question, please start a topic of your own. Feel free to provide a link to an old thread if relevant.
    Also, please don't solicit off-forum communication by email. This not only goes against the spirit of the forum, which is to share problems and their solutions, but will also fetch you plenty of spam, but rarely any help.
    I'm locking this thread now. It's more than 4½ years old.
    Also blocking both the posts soliciting off-forum communication.
    db

  • I've synced my phone, accidentally, to my wife's account and now lost all me photos and data... Is there any way of retrieving it all? The bigger problem is I can remember when my phone was last synced to my account so the info list is not on there either

    I've synced my phone, accidentally, to my wife's account and now lost all me photos and data... Is there any way of retrieving it all? The bigger problem is I can remember when my phone was last synced to my account so the info list is not on there either

    To see if there are any backups of your device on the computer, go to iTunes/Edit/Preferences/Devices.
    Moving the mouse over the listed backups will tell you to which device they belong.
    If there is no backup of your phone listed, your data is gone.
    In case you also used iCloud to back up your data, check this article:
    iOS: Back up and restore your iOS device with iCloud or iTunes

  • My iphone 4 was crushed on the road.  Bought a 4 replacement tried to restore it in itunes to get my contact info and it said there was a problem with my phone and I should contact mean

    My iphone 4 was crushed on the road.  Bought a 4 replacement tried to restore it in itunes to get my contact info and it said there was a problem with my phone and I should contact apple store.  What does that mean please?

    Is the replacement exactly the same as the original ie same memory size & same version? If so it may require updating the OS software before trying to restore your stuff from the backup.

  • HT201303 I wanted to download a song just now but had to verify my billing info...anyone else had a problem entering their card's security code? I couldn't do do this...so couldn't download the tune.

    I wanted to download a song just now but had to verify my billing info...anyone else had a problem entering their card's security code? I couldn't do do this...so couldn't download the tune.

    Amylovelyy wrote:
    Every time I try to download an app it says billing info is incorrect but its all correct ...
    Contact iTunes Customer Service and request assistance
    Use this Link  >  Apple  Support  iTunes Store  Contact
    Amylovelyy wrote:
    ...  it won't let me sign in using a diff apple id ...
    Settings > iTunes and App store > Apple ID = Sign Out... Then Sign In using the preferred Apple ID.
    It should be Noted that anything Downloaded with a Particular Apple ID is tied to that Apple ID and Cannot be Merged or Transferred to a Different Apple ID.

  • Problem in Sales Info Structure - Order Quantity is not calculated in EA.

    Dear all,
    My info structure is taking order quantity in not taking EA (Each) unit of measure. Instead it is taking from the CAR (Cartons).
    We maintained one carton is equal to 5 pieces.
    I want to disply order quantity in EA in my info structure.
    Your suggestions will be highly appreciated.
    Best regards,
    Raghu ram

    hello, friend.
    check in MC7F, select info structure S001 and see if there is an entry in the field 'Base Unit of Measure'. if the entry is 'CAR', either try changing it to 'Ea' or just leave it blank.
    regards.
    Dear Friend,
    I have checked my info structure in MC7F, the base unit of measure  field is blank. I have maintained EA in that field but it is not resulting any thing.
    in my info structure output just beside values system showing *** sybol instead of showing unit of measure.
    should I need to do any further config for this. Please help to solve the issue. I would be grateful for your help.
    Best regards,
    Raghu ram

  • Hotnews info retrieval problem.

    Hi all.
    I am trying to test and evaluate the Solution Manager4.0,
    and I am in a trouble with the HotNews functionality.
    I believe I have done all the necessary configurations, but following error message is shown when I try to check for the new notes: "Could not determine your customer number in the SAP back end system."
    If anyone have encountered with same problem, please please tell me what must be done to resolve this situation?
    thanks in advance.

    Hi uDo.
    Thanks for the reply.
    However, it still does not work.
    By saying RFC connection, I believe I have all RFC settings made correctly. Following three are set in Transaction SM59.
    1) SAPOSS
    2) SAP-OSS
    3) SAP-OSS-LIST-O01
    If I need additional connection setup for Hotnews, could you give some more detailed information about it?
    Thanks.

  • Data not retrieved in WebI with Measures calculated in Universe on SAPBW

    Hi,
    Pls share if such error is faced anywhere else and if there is any solution to this.
    Environment: SAP BI 7.01 and SAP BO XI 3.1 SP2 FP2.9
    Universe has calculated measures.
    Problem: No data is fetched by WebI when both direct measures (straight from BEx) and calculated measures are used.
    However, data is correctly retrieved if either only the direct measures are used or calculated measures are used.
    Thanks!

    Good CKF parsed for you @ Universe.
    If possible you can create Variable @WebI :
    Var=[Grs Sales] + [Returns]
    So that you can use it document (20 reports)
    This way you can solves the issue as of now.
    Gracias...!!

  • Income Tax Calculation problem: Urgent Help Needed

    Dear Gurus,
    I am facing a unique problem. Our client has two incentives –
    1) Product Incentive
    2) Sales Incentive
    Every month incentive figures get changed. These two are Monthly Regular Income (Cumulations Class 24) i.e. included in annual tax calculation.
    Now for tax calculation, my client wants "Actual Earning" and "Estimated Earning for the rest of the year" to be different. But Income tax calculation in SAP (for the month of April 2007) takes Actual Earning and multiplied it by 12( i.e. 11+1) to calculate Estimated Earning. But my client wants this Estimated Earning to be different. 
    Now please let me know is this possible in SAP system and how to calculate this?
    Your help will be highly appreciated
    Waiting for an early reply.
    Thanking You,
    With Best Regards,
    Pratik

    Hi,
    I am not understand your problem give your mb then i talk to you
    mhpo

  • Sale Analysis Profit Calculation problem

    Hello
    I create sale Invoice having Qty 2 unit price 150 & tax code is VAT@4% then Base amount is 300 & Total Bill
    amt is 312.
    My purchase price for the same item is INR 100 so my Gross profit show on Bill is INR 100 & profit percent
    is 33.33%
    Customer will debit with INR 312
    But when Create Rate difference bill ie credit memo of INR 20 per uint ie Qty 2 Tax VAT@4%  (maintain
    drop ship warehouse in row level to can't reduce the qty)
    Customer will debit -41.60
    So Customer Debit balance is 270.40
    But when I run Sale analysis report the result shows that Gross profit INR 260 & Gross Profit % is 100%
    But actually i calculated manually the real Profit is INR 60 & Profit % should be 23.08 should be show in sale
    analysis
    So what i do to see the same result

    Hi
    There is some problem in sales analysis report in some of the sap versions. Refer the following documents.
    [https://websmp130.sap-ag.de/sap(bD1lbiZjPTAwMQ==)/bc/bsp/sno/ui_entry/entry.htm?param=69765F6D6F64653D3030312669765F7361706E6F7465735F6E756D6265723D3030303130313637303426]
    [https://websmp130.sap-ag.de/sap(bD1lbiZjPTAwMQ==)/bc/bsp/sno/ui_entry/entry.htm?param=69765F6D6F64653D3030312669765F7361706E6F7465735F6E756D6265723D3135383735363826]
    [https://websmp130.sap-ag.de/sap(bD1lbiZjPTAwMQ==)/bc/bsp/sno/ui_entry/entry.htm?param=69765F6D6F64653D3030312669765F7361706E6F7465735F6E756D6265723D3136363835363426]
    Regards,
    Sudhir B.

  • Large numbers calculation problem (determinant calculation)

    Hello experts,
    I have really interesting problem. I am calculatig determinant in ABAP with a large numbers (in CRM 5.0 system).
    My formula for determinant is :
    FORM calculate_determinant USING    det      TYPE zsppo_determinant
                               CHANGING value    TYPE f .
      value =
        (  1 * det-a11 * det-a22 * det-a33 * det-a44 ) + ( -1 * det-a11 * det-a22 * det-a34 * det-a43 ) +
        ( -1 * det-a11 * det-a23 * det-a32 * det-a44 ) + (  1 * det-a11 * det-a23 * det-a34 * det-a42 ) +
        ( -1 * det-a11 * det-a24 * det-a33 * det-a42 ) + (  1 * det-a11 * det-a24 * det-a32 * det-a43 ) +
        ( -1 * det-a12 * det-a21 * det-a33 * det-a44 ) + (  1 * det-a12 * det-a21 * det-a34 * det-a43 ) +
        (  1 * det-a12 * det-a23 * det-a31 * det-a44 ) + ( -1 * det-a12 * det-a23 * det-a34 * det-a41 ) +
        ( -1 * det-a12 * det-a24 * det-a31 * det-a43 ) + (  1 * det-a12 * det-a24 * det-a33 * det-a41 ) +
        (  1 * det-a13 * det-a21 * det-a32 * det-a44 ) + ( -1 * det-a13 * det-a21 * det-a34 * det-a42 ) +
        ( -1 * det-a13 * det-a22 * det-a31 * det-a44 ) + (  1 * det-a13 * det-a22 * det-a34 * det-a41 ) +
        (  1 * det-a13 * det-a24 * det-a31 * det-a42 ) + ( -1 * det-a13 * det-a24 * det-a32 * det-a41 ) +
        ( -1 * det-a14 * det-a21 * det-a32 * det-a43 ) + (  1 * det-a14 * det-a21 * det-a33 * det-a42 ) +
        (  1 * det-a14 * det-a22 * det-a31 * det-a43 ) + ( -1 * det-a14 * det-a22 * det-a33 * det-a41 ) +
        ( -1 * det-a14 * det-a23 * det-a31 * det-a42 ) + (  1 * det-a14 * det-a23 * det-a32 * det-a41 )
    ENDFORM.
    Det values are also f type. Problem is, that for several numbers I got the right values and for another det values I got wrong values... I also try to retype variable value on type p, but without success. Maybe I used wrong types or there is some ABAP rounding of numbers which cause wrong result.
    Any good ideas of solutions. <text removed>. Thanks for your time.
    Edited by: Matt on Sep 14, 2010 9:17 AM

    Hi Lubos,
    phew! that sounds far from SAP scope, but from Maths' numerical methods. Let's see if I can remember something about my lessons at University...
    - One issue can arise when adding and subtracting terms which are very similar, because the error tends to arise quite fast. Try to add the positive terms on one hand, and the negative terms on the other hand, then subtract one from the other.
    - Please take into account that the determinant value can be significantly close to zero when the condition number of the matrix is low, that is, when the range is 4 but the whole determinant is close to 0. Instead, try a [Singular Value Decomposition|http://en.wikipedia.org/wiki/SVD_(mathematics)] or an [LU decomposition|http://en.wikipedia.org/wiki/LU_decomposition]
    I hope this helps. Kind regards,
    Alvaro

  • [8i] Date/Time calculation problem...

    So, I am currently facing a situation where I need to calculate the total hours a workstation is in use for each day in a particular time period. I have a table with the log of each time each workstation is used. The problem is, a workstation can be used for any amount of time, starting on any day and ending on any day. This means that a particular entry in the log can span multiple days. I'm not sure how to split the difference between the end date/time of an entry and the start date/time of the entry over multiple days.
    Here's a sample table and some sample data for what I'm trying to do:
    -- Note: in reality, this table contains more columns
    CREATE TABLE     my_hrs
    (     record_id     NUMBER     NOT NULL
    ,     sdatetime     DATE     
    ,     edatetime     DATE     
    ,     workstation     VARCHAR2(4)
         CONSTRAINT my_hrs_pk PRIMARY KEY (record_id)
    -- Note: sdatetime, edatetime, and workstation CAN all be NULL, though I won't provide
    -- any sample data for these situations since I want to ignore them in my results
    -- Additionally, there are hundreds of workstations, but I'm only using 2 to simplify the sample data
    INSERT INTO     my_hrs
    VALUES (12345,TO_DATE('03/01/2010 08:00','mm/dd/yyyy HH24:MI'),TO_DATE('03/01/2010 13:35','mm/dd/yyyy HH24:MI'),'123A');
    INSERT INTO     my_hrs
    VALUES (13427,TO_DATE('03/01/2010 08:10','mm/dd/yyyy HH24:MI'),TO_DATE('03/01/2010 10:02','mm/dd/yyyy HH24:MI'),'321B');
    INSERT INTO     my_hrs
    VALUES (21543,TO_DATE('03/01/2010 14:07','mm/dd/yyyy HH24:MI'),TO_DATE('03/01/2010 16:30','mm/dd/yyyy HH24:MI'),'123A');
    INSERT INTO     my_hrs
    VALUES (22412,TO_DATE('03/01/2010 10:15','mm/dd/yyyy HH24:MI'),TO_DATE('03/01/2010 15:30','mm/dd/yyyy HH24:MI'),'321B');
    INSERT INTO     my_hrs
    VALUES (11976,TO_DATE('03/01/2010 17:00','mm/dd/yyyy HH24:MI'),TO_DATE('03/02/2010 02:30','mm/dd/yyyy HH24:MI'),'123A');
    INSERT INTO     my_hrs
    VALUES (34215,TO_DATE('03/01/2010 22:10','mm/dd/yyyy HH24:MI'),TO_DATE('03/02/2010 04:30','mm/dd/yyyy HH24:MI'),'321B');
    INSERT INTO     my_hrs
    VALUES (24789,TO_DATE('03/02/2010 13:00','mm/dd/yyyy HH24:MI'),TO_DATE('03/05/2010 02:30','mm/dd/yyyy HH24:MI'),'123A');
    INSERT INTO     my_hrs
    VALUES (31542,TO_DATE('03/02/2010 21:30','mm/dd/yyyy HH24:MI'),TO_DATE('03/04/2010 10:30','mm/dd/yyyy HH24:MI'),'321B');Based on my sample data above, these are the results I want to see:
    WORKSTATION     DATE          HRS_IN_USE
    123A          3/1/2010     14.96667
    321B          3/1/2010     8.95000
    123A          3/2/2010     13.50000
    321B          3/2/2010     7.00000
    123A          3/3/2010     24.00000
    321B          3/3/2010     24.00000
    123A          3/4/2010     24.00000
    321B          3/4/2010     10.50000
    123A          3/5/2010     2.50000
    321B          3/5/2010     0.00000Is this possible? (Please note, if the workstation was not used on a particular day, I want it to show 0 hours for that workstation for that day). Another thing to note is that I'm working with Oracle 8i.
    Thanks in advance for the help!

    Thanks, Frank, your explanation helped. My main problem was just that I couldn't picture what that line of the query was doing, even working from the inside out. I learn better through visual and hands-on methods, so to really understand, I had to look at the cross-join of a and h and go line by line. (In case there's anybody who looks at this post in the future and learns like I do, I've posted that data below).
    This definitely solves my problem!
    >
    By the way, this query is full of things that could be done better in later versions of Oracle. Generating table a is just one of them. Starting in Oracle 9, you can do a CONNECT BY query on dual to generate exacly how many rows you need. You never have to worry about an upper bound, and it's much faster than using ROWNUM. From time to time you might gently remind the people who decide these things that you're using a very old, unsupported version of Oracle, and that everyone could be more productive if you upgraded.
    >
    I could go on and on on this topic.... we have tried and continue to try to convince the powers that be to pay for the upgrades... if it were just Oracle that needed to be upgraded, we might actually have a chance at succeeding. As it is, ...ha.
    TABLE A (FROM SUB-QUERY)
    a_date          next_date
    3/1/2010     3/2/2010
    3/2/2010     3/3/2010
    3/3/2010     3/4/2010
    3/4/2010     3/5/2010
    3/5/2010     3/6/2010
    TABLE H (MY_HRS)          
    record_id     sdatetime     edatetime     workstation
    10000          2/28/2010 18:00     3/1/2010 5:30     123A
    12345          3/1/2010 8:00     3/1/2010 13:35     123A
    13427          3/1/2010 8:10     3/1/2010 10:02     321B
    21543          3/1/2010 14:07     3/1/2010 16:30     123A
    22412          3/1/2010 10:15     3/1/2010 15:30     321B
    11976          3/1/2010 17:00     3/2/2010 2:30     123A
    34215          3/1/2010 22:10     3/2/2010 4:30     321B
    24789          3/2/2010 13:00     3/5/2010 2:30     123A
    31542          3/2/2010 21:30     3/4/2010 10:30     321B
    CROSS-JOIN TABLE A WITH TABLE H                                             (and calculations done by the query below)     
    record_id     sdatetime     edatetime     workstation     a_date          next_date     LEAST (h.edatetime, a.next_date)     GREATEST (h.sdatetime, a.a_date)     GREATEST(TO_NUMBER(L-G),0)
    10000          2/28/2010 18:00     3/1/2010 5:30     123A          3/1/2010     3/2/2010     3/1/2010 5:30                    3/1/2010 0:00                    0.229166667
    10000          2/28/2010 18:00     3/1/2010 5:30     123A          3/2/2010     3/3/2010     3/1/2010 5:30                    3/2/2010 0:00                    0.00000
    10000          2/28/2010 18:00     3/1/2010 5:30     123A          3/3/2010     3/4/2010     3/1/2010 5:30                    3/3/2010 0:00                    0.00000
    10000          2/28/2010 18:00     3/1/2010 5:30     123A          3/4/2010     3/5/2010     3/1/2010 5:30                    3/4/2010 0:00                    0.00000
    10000          2/28/2010 18:00     3/1/2010 5:30     123A          3/5/2010     3/6/2010     3/1/2010 5:30                    3/5/2010 0:00                    0.00000
    12345          3/1/2010 8:00     3/1/2010 13:35     123A          3/1/2010     3/2/2010     3/1/2010 13:35                    3/1/2010 8:00                    0.23264
    12345          3/1/2010 8:00     3/1/2010 13:35     123A          3/2/2010     3/3/2010     3/1/2010 13:35                    3/2/2010 0:00                    0.00000
    12345          3/1/2010 8:00     3/1/2010 13:35     123A          3/3/2010     3/4/2010     3/1/2010 13:35                    3/3/2010 0:00                    0.00000
    12345          3/1/2010 8:00     3/1/2010 13:35     123A          3/4/2010     3/5/2010     3/1/2010 13:35                    3/4/2010 0:00                    0.00000
    12345          3/1/2010 8:00     3/1/2010 13:35     123A          3/5/2010     3/6/2010     3/1/2010 13:35                    3/5/2010 0:00                    0.00000
    13427          3/1/2010 8:10     3/1/2010 10:02     321B          3/1/2010     3/2/2010     3/1/2010 10:02                    3/1/2010 8:10                    0.07778
    13427          3/1/2010 8:10     3/1/2010 10:02     321B          3/2/2010     3/3/2010     3/1/2010 10:02                    3/2/2010 0:00                    0.00000
    13427          3/1/2010 8:10     3/1/2010 10:02     321B          3/3/2010     3/4/2010     3/1/2010 10:02                    3/3/2010 0:00                    0.00000
    13427          3/1/2010 8:10     3/1/2010 10:02     321B          3/4/2010     3/5/2010     3/1/2010 10:02                    3/4/2010 0:00                    0.00000
    13427          3/1/2010 8:10     3/1/2010 10:02     321B          3/5/2010     3/6/2010     3/1/2010 10:02                    3/5/2010 0:00                    0.00000
    21543          3/1/2010 14:07     3/1/2010 16:30     123A          3/1/2010     3/2/2010     3/1/2010 16:30                    3/1/2010 14:07                    0.09931
    21543          3/1/2010 14:07     3/1/2010 16:30     123A          3/2/2010     3/3/2010     3/1/2010 16:30                    3/2/2010 0:00                    0.00000
    21543          3/1/2010 14:07     3/1/2010 16:30     123A          3/3/2010     3/4/2010     3/1/2010 16:30                    3/3/2010 0:00                    0.00000
    21543          3/1/2010 14:07     3/1/2010 16:30     123A          3/4/2010     3/5/2010     3/1/2010 16:30                    3/4/2010 0:00                    0.00000
    21543          3/1/2010 14:07     3/1/2010 16:30     123A          3/5/2010     3/6/2010     3/1/2010 16:30                    3/5/2010 0:00                    0.00000
    22412          3/1/2010 10:15     3/1/2010 15:30     321B          3/1/2010     3/2/2010     3/1/2010 15:30                    3/1/2010 10:15                    0.21875
    22412          3/1/2010 10:15     3/1/2010 15:30     321B          3/2/2010     3/3/2010     3/1/2010 15:30                    3/2/2010 0:00                    0.00000
    22412          3/1/2010 10:15     3/1/2010 15:30     321B          3/3/2010     3/4/2010     3/1/2010 15:30                    3/3/2010 0:00                    0.00000
    22412          3/1/2010 10:15     3/1/2010 15:30     321B          3/4/2010     3/5/2010     3/1/2010 15:30                    3/4/2010 0:00                    0.00000
    22412          3/1/2010 10:15     3/1/2010 15:30     321B          3/5/2010     3/6/2010     3/1/2010 15:30                    3/5/2010 0:00                    0.00000
    11976          3/1/2010 17:00     3/2/2010 2:30     123A          3/1/2010     3/2/2010     3/2/2010 0:00                    3/1/2010 17:00                    0.29167
    11976          3/1/2010 17:00     3/2/2010 2:30     123A          3/2/2010     3/3/2010     3/2/2010 2:30                    3/2/2010 0:00                    0.10417
    11976          3/1/2010 17:00     3/2/2010 2:30     123A          3/3/2010     3/4/2010     3/2/2010 2:30                    3/3/2010 0:00                    0.00000
    11976          3/1/2010 17:00     3/2/2010 2:30     123A          3/4/2010     3/5/2010     3/2/2010 2:30                    3/4/2010 0:00                    0.00000
    11976          3/1/2010 17:00     3/2/2010 2:30     123A          3/5/2010     3/6/2010     3/2/2010 2:30                    3/5/2010 0:00                    0.00000
    34215          3/1/2010 22:10     3/2/2010 4:30     321B          3/1/2010     3/2/2010     3/2/2010 0:00                    3/1/2010 22:10                    0.07639
    34215          3/1/2010 22:10     3/2/2010 4:30     321B          3/2/2010     3/3/2010     3/2/2010 4:30                    3/2/2010 0:00                    0.18750
    34215          3/1/2010 22:10     3/2/2010 4:30     321B          3/3/2010     3/4/2010     3/2/2010 4:30                    3/3/2010 0:00                    0.00000
    34215          3/1/2010 22:10     3/2/2010 4:30     321B          3/4/2010     3/5/2010     3/2/2010 4:30                    3/4/2010 0:00                    0.00000
    34215          3/1/2010 22:10     3/2/2010 4:30     321B          3/5/2010     3/6/2010     3/2/2010 4:30                    3/5/2010 0:00                    0.00000
    24789          3/2/2010 13:00     3/5/2010 2:30     123A          3/1/2010     3/2/2010     3/2/2010 0:00                    3/2/2010 13:00                    0.00000
    24789          3/2/2010 13:00     3/5/2010 2:30     123A          3/2/2010     3/3/2010     3/3/2010 0:00                    3/2/2010 13:00                    0.45833
    24789          3/2/2010 13:00     3/5/2010 2:30     123A          3/3/2010     3/4/2010     3/4/2010 0:00                    3/3/2010 0:00                    1.00000
    24789          3/2/2010 13:00     3/5/2010 2:30     123A          3/4/2010     3/5/2010     3/5/2010 0:00                    3/4/2010 0:00                    1.00000
    24789          3/2/2010 13:00     3/5/2010 2:30     123A          3/5/2010     3/6/2010     3/5/2010 2:30                    3/5/2010 0:00                    0.10417
    31542          3/2/2010 21:30     3/4/2010 10:30     321B          3/1/2010     3/2/2010     3/2/2010 0:00                    3/2/2010 21:30                    0.00000
    31542          3/2/2010 21:30     3/4/2010 10:30     321B          3/2/2010     3/3/2010     3/3/2010 0:00                    3/2/2010 21:30                    0.10417
    31542          3/2/2010 21:30     3/4/2010 10:30     321B          3/3/2010     3/4/2010     3/4/2010 0:00                    3/3/2010 0:00                    1.00000
    31542          3/2/2010 21:30     3/4/2010 10:30     321B          3/4/2010     3/5/2010     3/4/2010 10:30                    3/4/2010 0:00                    0.43750
    31542          3/2/2010 21:30     3/4/2010 10:30     321B          3/5/2010     3/6/2010     3/4/2010 10:30                    3/5/2010 0:00                    0.00000
    (Then, the query sums up the last column in the "table" above, grouped by a_date and workstation).

  • Alternative sales commission calculation problem

    hi sir,
    I am a junior consultant trying to solve a problem for my Senior, the question goes as follows:
    We are trying to impute sales commissions to sales rep as a discount for every sale, in which for every sale a determined amount is imputed to the sales rep as a commission.
    the problem arises when the product is returned and customer asks for a refund. Then the commission should be refunded aswell. Could you please throw some light to wether we should clear that invoice the same month or the next one as a negative pendent discount, if so, how is the negative imputation applied?
    thanks a lot in advance,
    HF

    Bobsterslc wrote:
    Here is a screenshot of a piece of what I'm working on.
    Hi Bob,
    Here's what your screenshot looks like when embedded in a post, using the HTML code that Photobucket provides (third item in the list of codes provided).
    In your original post you said:
    I have a table that calculates sales commissions for a number of people and includes an overriding commission for the sales managers. I need to cap the sales commission at a fixed percentage, say 25%, for the sales people.
    I'm not sure what you mean by "I need to cap the sales commission at a fixed percentage."
    The first question that comes to mind is "25% of what?"
    Do you mean that the commission is not to exceed 25% of Total earnings?
    If so, your formula for B5 (the first cell where commission is calculated) would be:
    =MIN(formula1,B2/3)
    Where formula1 is whatever formula is used to calculate the commission when it is less than the cap, and B2 contains the salary/wages which must constitute at least 75% of the total compensation under this interpretation.
    Do you mean the commission rate is on a sliding scale that rises with increased sales, but does not exceed 25%?
    If so, you need to specify the rules that control the rate. Does it rise in steps? Does the 'new' rate at each step apply to total sales, or only to sales above that step? Are the steps the same size for everyone, directly related to the individual goals, or set by some other criteria?
    There's not enough information available fom your table to determine a pattern. For the first three columns, person B's commission is 12% of sales, person C's is under 4% and person D's is 30% of sales.
    For a more detailed response, we'll ned a more detailed specification of the question.
    Regards,
    Barry

  • Date Difference Calculation problem

    I am creating a form which should calculate the number of days between two calender dat
    es using the Date2Sum expression but my result cell gives me
    zeo despite setting the locale and the calculation correcttly. Where could
    my problem be?
    Darlington Sakwa

    Validate the date patterns on the date fields match the date patterns used in Date2Num. For example, the attached has a start date with the display date pattern date{YYYY-MM-DD} and that matches the date pattern in my Date2Num function call.
    // form1.page1.startDateNum::calculate - (FormCalc, client)
    if (form1.page1.startDate.isNull) then
      $.rawValue = ""
    else
      $.rawValue = Date2Num(form1.page1.startDate.rawValue,"YYYY-MM-DD")
    endif
    Steve

  • Y-intercept calculation problem: "A2:A7" isn't a valid reference

    This is actually a problem I have with many calculations in Numbers but I will use the following as an example:
    I am trying to calculate the y-intercept and slope for a set of data. Table 1 contains the raw data with each data point in triplicate. In Table 2, column 1 is the ordinate value and column 2 is the abscissa value, which is the average of the triplicates. I would like to place the calculation for the y-intercept in column 3 and the slope in column 4, but always get the error, "A2:A7" isn't a valid reference" for a result. Instead, I have to have a third table for just the y-int and slope. Why isn't A2:A7 a valid reference?

    No, I didn't; I only had a 5 rows but I made it 7 rows - so it was a 4 column x 7 row table - and then the formulas worked. The odd thing is that there was still only data in the first 5 rows and, after I set up the formulas, I reduced the table back to 4x7 and the formulas remained unchanged. Thanks for the help.

Maybe you are looking for

  • Service order with TAW or TAX

    hi friend !!!! we can use TAX item catogory also other than TAW but i observed one thing when i create service order with both material (service and trading ) and create their delivery and invoice in document flow of order system can't show the PGI M

  • Is there a lightning cable for my old iPad2?

    My iPad 2 is very slow charging. Is there a faster cable available for it, either Apple or maybe Belkin? Thanks!

  • Dialogue instance not starting up after performing stack upgrade.

    Dear Experts, We have performed stack upgrade on ERP 6.0 EHP5 system. In configuration phase we have not got the option to update dialog instances. We proceeded without that option and completed the upgrade successfully but the dialog instance is not

  • Add ALPHA-conversion to existing InfoObject

    I want to add ALPHA conversion to an existing InfoObject (BW7.0). However the transaction RSMDEXITON which used to perform the data conversion does not work anymore in BW7.0 Are there any alternatives?

  • Cannot use presets

    I have the education version of AE CS4. Cannot use any of the animation presets. get an error message "unsupported file or extension" when I double click a preset in Bridge. Does the EDU version not allow this or do I have a bug or user error.. Macbo