-
1. Re: Crosstab - array error
BACFL May 7, 2014 7:27 AM (in response to BACFL)An update.
this line: <CFSET temp = ArraySet(course_idarray, 0, b, "N/A")>
Should be: <CFSET temp = ArraySet(course_idarray, 1, b, "N/A")>
-
2. Re: Crosstab - array error
BKBK May 11, 2014 1:47 AM (in response to BACFL)3 remarks:
- The line <CFSET temp = ArraySet(course_idarray, 1, b, "N/A")> should be put outside the cfoutput loop. There is no need for it to run at every pass of the loop.
- The cfoutput tag within <cfoutput query="crosstabquery"> is unnecessary.
- The line <CFSET temp = ArraySet(course_idarray, i, i, crosstabquery.dsckcrse)> is perhaps equivalent to <CFSET course_idarray[i] = crosstabquery.dsckcrse)>
-
3. Re: Crosstab - array error
BKBK May 11, 2014 1:48 AM (in response to BACFL)0 is not greater than zero or less than or equal to 0.
I shall report that error message as a bug. It is false. It should read: "0 is not greater than zero and less than or equal to 0."
-
4. Re: Crosstab - array error
BACFL May 12, 2014 7:35 AM (in response to BKBK)Hi BKBK!
I appreciate your assistance. What appears to have been the problem here from some research that I did is that a Cold Fusion array does not start with zero, it starts with 1. So I changed the array to: "
<CFSET temp = ArraySet(bucketarray, 1, 2, crosstabquery.amount)>" so that the count starts with 1 and the next count is 2.
Here is my updated code, for which as you can see below the COUNT that I added is not working properly.
<CFQUERY NAME="crosstabquery" DATASOURCE="LIISthinkgate">
SELECT distinct teacher_anumber,dsckcrse,dscgrd, count(dsckextid) as amount
FROM evaluationstudentcourse
WHERE teacher_anumber = 'A054863'
group by teacher_anumber,dsckcrse,dscgrd
ORDER BY teacher_anumber,dscgrd,dsckcrse
</CFQUERY><CFQUERY NAME="crosstabcolumns" DBTYPE="query">
SELECT distinct dsckcrse
FROM crosstabquery
WHERE dsckcrse = crosstabquery.dsckcrse
ORDER BY dsckcrse
</CFQUERY>
<CFSET bucketlist = ValueList(crosstabcolumns.dsckcrse)><CFSET bucketheaders = ListToArray(bucketlist)>
<CFSET b = ArrayLen(bucketheaders)>
<CFSET bucketarray = ArrayNew(1)>
<CFSET temp = ArraySet(bucketarray
, 1, b, "N/A")><CFOUTPUT QUERY="crosstabquery" GROUP="teacher_anumber">
<h4>Anumber=#teacher_anumber#</h4>
<table border="1" cellpadding="5">
<tr><th></th>
<CFLOOP INDEX="i" FROM="1" TO="#b#">
<th>#bucketheaders[i]#</th>
</CFLOOP>
</tr>
<CFOUTPUT GROUP="dsckcrse">
<tr><th>#dscgrd#</th>
<CFSET i = ListFind(bucketlist
, crosstabquery.dscgrd)>
<CFSET temp = ArraySet(bucketarray
, 1, 2, crosstabquery.amount)>
<CFLOOP index="j" FROM="1" TO="#b#">
<td>#crosstabquery.amount#</td>
</CFLOOP>
</tr>
</CFOUTPUT>
</table>
</CFOUTPUT>I got rid of the original error, however I am now not getting "0" where there should be no count. For instance 5001020 (dsckcrse), 02 (dscgrd) should have 136. The others (01,03,04,05,KG) should be zero. I get the following:
Anumber=A054863
5001010 5001020 5001030 5001040 5001050 5001060 01 120 120 120 120 120 120 02 136 136 136 136 136 136 03 145 145 145 145 145 145 04 163 163 163 163 163 163 05 165 165 165 165 165 165 KG 117 117 117 117 117 117
Appreciate any insight you have. -
5. Re: Crosstab - array error
BKBK May 12, 2014 12:37 PM (in response to BACFL)Please see my first post.

