Skip to main content
August 25, 2011
Question

QuerySetCell adding row data

  • August 25, 2011
  • 1 reply
  • 1225 views

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 has been closed for replies.

    1 reply

    Inspiring
    August 25, 2011

    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

    August 25, 2011

    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])>

    Inspiring
    August 25, 2011

    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