Skip to main content
Aug 25, 2011 5:05 PM UTC
Question

QuerySetCell adding row data

I'm using querysetcell to display data from an sql query.  the trouble i'm having is not being able to add the numbers in a row. 

c1     c2    c3          c4         c5      c6     c7   Total ?

849710,3231,9921,80901950

<cfset querySetCell(qPivot, 'dept_' & tmpDeptCode, numCredits)>  This gets me number portion above.  How do I get them to add into one number?

    This topic is closed to new replies. Start a new post to keep the conversation going.

    5 replies

    Inspiring
    Aug 25, 2011 5:52 PM UTC

    There's no special way.  You just have to add the numbers up and put the result into the other cell.

    querySetCell(q, "col1", 1);

    querySellCell(q, "col2", 2);

    querySetCell(q, "col3", q.col1[q.currentRow]+q.col2[q.currentRow]);

    It's not a spreadsheet: there's no functions or anything you can use, it's just a "dumb" data structure like an array or a struct (except with both rows and columns, rather than just one or the other).

    --

    Adam

    Translate
    Aug 25, 2011 6:32 PM UTC

    Adam,

      Thanks, I didn't get an error, however the number 7 is showing up for each row in the GrandTotal Column.  This is what I did.

    <cfset querySetCell(qPivot, "GrandTotal", dept_UBS[qPivot.currentRow] + dept_FEDU[qPivot.currentRow]
                     +dept_B_UG[qPivot.currentRow] + dept_UHMN[qPivot.currentRow]
               +dept_UM_T[qPivot.currentRow] + dept_LAW[qPivot.currentRow]
               +dept_UPVA[qPivot.currentRow])>

    Translate
    Inspiring
    Aug 25, 2011 6:49 PM UTC

    You might wanna output your query values and your currentRow value on the screen and check the numbers are what you think they are.

    And you might need to post more code... I presume there's a loop around this stuff or something?

    --

    Adam

    Translate