ColdFusion CFchart and feedback form - coldfusion

I am creating a feedback form system where users can fill in feedback forms and admin users will be able to run reports against the answers. I am trying to use cfchart to display the results in an easy to read manner for the administrators.
Here is my code:
&ltcfquery name="getFeedbackresults" datasource="#application.dsn#">
SELECT ff.feedbackFormId
,ff.feedbackFormName
,ff.feedbackFormDescription
,ff.activeFrom
,ff.activeTo
,ff.feedbackCountry
,ffq.question
,ffa.answer
,ffq.feedbackQuestionTypeId
,count(answer) AS distinctAnswer
FROM feedbackForm ff
,feedbackFormQuestion ffq
,feedbackFormInstance ffi
,feedbackFormAnswer ffa
WHERE ff.feedbackFormId = ffq.feedbackFormId
AND ff.feedbackFormId = ffi.feedbackFormId
AND ffi.feedbackFormInstanceId = ffa.feedbackFormInstanceId
AND ffa.feedbackQuestionId = ffq.feedbackQuestionId
AND ffq.feedbackQuestionTypeId not in (2,3)
GROUP BY ff.feedbackFormId, ff.feedbackFormName, ff.feedbackFormDescription, ff.feedbackCountry, ffq.question, ff.activeFrom, ffq.feedbackQuestionTypeId, ff.activeTo, ffa.answer
ORDER BY question
&lt/cfquery>
&ltcfoutput>
&lth2>#getFeedbackresults.feedbackFormName# Results&lt/h2>
&lth3>Description:
&ltp>#getFeedbackresults.feedbackFormDescription#&lt/p>
&ltul>
&ltli>&ltstrong>Active From: &lt/strong>#getFeedbackresults.activeFrom#&lt/li>
&ltli>&ltstrong>Active To: &lt/strong>#getFeedbackresults.activeTo#&lt/li>
&ltli>&ltstrong>Country: &lt/strong>#getFeedbackresults.feedbackCountry#&lt/li>
&lt/ul>
&lt/cfoutput>
&ltcfdump var="#getFeedbackresults#">
&ltcfchart format="flash" xaxistitle="Questions" yaxistitle="Answers" show3d="yes" chartheight="400" chartwidth="400">
&ltcfoutput query="getFeedbackresults" group="answer">
&ltcfchartseries type="bar" serieslabel="#answer#">
&ltcfchartdata item="#question#" value="#distinctAnswer#">
&lt/cfchartseries>
&lt/cfoutput>
&lt/cfchart>
The problem I am having is that the chart is displaying each list of answers in every series. I tried to upload an image but as I am a new user I'm not allowed. If anyone would like the image I can send it to them.
Any help would be greatfully appreciated.

You need to sort your query by the answer column if that's what you're going to group by. Your current ORDER BY is "question". Once you're sorting the same value that you're using for the group attribute on your cfoutput, you should be good to go.

Related

Replace blanks with a string with DAX coding in Power BI

I have a data in Excel and I have uploaded in power bi, created a visualisation using a chart which looks like -
blank, CP, Jj10 are basically my y axis and dashes are my bars of horizontal chart. I have tried to show how my chart looks like because I don't get any other option
(Blank)-------------998
CP-----------56
Jj10--------44
0BN--------------77
Hi-po---2
Naas-------21
There is a column named performance (sheet_name=Empl_data) and what I want is to replace the blanks with Non-GT in power bi with creating a new column.
What my output should look like -
(Non-GT)-------------998
CP-----------56
Jj10--------44
0BN--------------77
Hi-po---2
Naas-------21
I have tried this -
Non-GT = IF(ISBLANK('Empl_data'[performance]),"Non-GT",'Empl_data'[performance])
What i get is
Non-GT----------------964
(Blank)-------------34
CP-----------56
Jj10--------44
0BN--------------77
Hi-po---2
Naas-------21
I just want to replace blanks with Non-TSG completely but still it shows blank. Please help me out to solve the problem and please let me know if I have made clear what my prblm is.
My data -
Empl_id
Empl_name
performance
99807
Somman paul
0076
Richards.M
8870
Maheen Josef.T
11209
Dojar Farah
6651
Macklegn Sagoe
Hi-po
551
Cada Farez
Jj10
12
Qwezy Goha
Hi-po
6567
Beheriop Produse
CP
2227
John semmers
0BN
656
Majeeio .f
80100
Drejju Yan
Is it actually Blank where it is showing nothing? First confirm there are spaces or really null in the data, then apply conditions as bellow-
Non-GT =
IF(
'Empl_data'[performance] = BLANK() || 'Empl_data'[performance] = "",
"Non-GT",
'Empl_data'[performance]
)
Q: Where you are transforming data with that condition? Power Query Editor? Or creating Measure or Calculated column?

How to load specific columns with varying location from a text file in python?

I'm trying to read the discharge data of 346 US rivers stored online in textfiles. The files are more or less in this format:
Measurement_number Date Gage_height Discharge_value
1 2017-01-01 10 1000
2 2017-01-20 15 2000
# etc.
I only want to read the gage height and discharge value columns.
The problem is that in most files additional columns with metadata are added in front of the 'Gage height' column, so i can not just simply read the 3rd and 4th column because their index varies.
I'm trying to find a way to say 'read the columns with the name 'Gage_height' and 'Discharge_value'', but I haven't succeeded yet.
I hope anyone can help. I'm currently trying to load the text files with numpy.genfromtxt so it would be great to find a solution with that package but other solutions are also more than welcome.
This is my code so far
data_url=urllib2.urlopen(#the url of this specific site)
data=np.genfromtxt(data_url,skip_header=1,comments='#',usecols=2,3])
You can use the names=True option to genfromtxt, and then use the column names to select which columns you want to read with usecols.
For example, to read 'Gage_height' and 'Discharge_value' from your data file:
data = np.genfromtxt(filename, names=True, usecols=['Gage_height', 'Discharge_value'])
Note that you don't need to set skip_header=1 if you use names=True.
You can then access the columns using their names:
gage_height = data['Gage_height'] # == array([ 10., 15.])
discharge_value = data['Discharge_value'] # == array([ 1000., 2000.])
See the docs here for more information.

Different color for table of contents entry and page numbers

I am generating a clickable (=with links) table of contents. In order to emphasize the 'clickability' of the entries I want them colored as links (i.e. blue color and underline).
I have this code for setting the style:
toc = TableOfContents()
toc.levelStyles[0].fontName = 'Arial Bold'
toc.levelStyles[0].fontSize = 12
toc.levelStyles[0].textColor = '#0000cc'
and use this code to add each entry:
toc.addEntry(0, '<u>' + entrytext + '</u>', pageNum, str(id(page)))
It works ok, the problem is that page numbers turn out blue as well. I tried to look around SO and the user guide for ways to put a different style for each - but was unsuccessful. Any ideas?
Thanks.

Add leading '$' to google charts

I am working with Google Charts. I need to add a '$' before the values on the y-axis as well as the value in the bubbles.
Is there a setting for this?
take care,
lee
UPdate,
Here is the data being used by the charts:
'Month','Semi-Detached in Toronto E04','Semi-Detached in Toronto E08','Condominium Townhouse in Toronto E04','Condominium Townhouse in Toronto E08', ],
['7/2011', 4354000,15305800,6776500,495000],['8/2011', 700000,10514418,7060786,0],['9/2011', 6854800,17805400,12087300,0],['10/2011', 7287400,14248900,16206500,0],['11/2011', 2696245,9733270,12698090,0],['12/2011', 1965800,6054500,8854390,0],['1/2012', 2450968,9012200,5500100,0] ]);
I've tried adding '$' before the values as well as '%24' as suggested before, but both throw syntax errors. And the values cannot be quoted without throwing a Google Charts error '
Data column(s) for axis #0 cannot be of type stringĂ—'.
Thanks everyone for your input. I found a question that was 99.9% the same:
How to set tooltips to display percentages to match axis in Google Visualization Line Chart?
Try using %24 which is the urlencoded form for $.
Use:
var formatter = new google.visualization.NumberFormat({prefix: '$'});
Check the example here:
https://developers.google.com/chart/interactive/docs/examples#interaction_example
More details here:
https://developers.google.com/chart/interactive/docs/reference#numberformatter

ColdFusion paging and page numbers

I have a list of user comments stored in a database and I'm displaying 10 per page. On page load I need to dynamically render the appropriate amount of page numbers. At first I thought I would just get the total amount of comments and divide that by 10 to get the # of pages. That however doesn't work correctly. For example:
1. 1-10
2. 11-21
3. 22-32
4. 33-43
5. 44-54
6. 55-65
7. 66-76
So basically with my original math if I have 70 results I will have 7 pages, but if I have 71 results I get 8 pages, which obviously isn't correct. How can I fix this?
Here's my original code:
<cfset commentsNumber = getComments.recordcount / 10>
<cfloop from="1" to="#commentsNumber#" index="i" >
<cfoutput>
#i#
</cfoutput>
</cfloop>
Edit: I can't do math today :(
...if I have 71 results I get 8 pages, which obviously isn't correct.
10 results per page w/ 71 results is 8 pages. What's wrong?
If you want to be sure of your record paging in ColdFusion, you could use an open source library like Pagination.cfc. It handles all the math for you and gives you a customizable display.
hey correct you math first.. :) your example is wrong.
If you are showing 10 comments per page then it should be
1. 1-10
2. 11-20
3. 21-30
etc
By the way you can use CFGRID for paging... it's very simple..