CodingSome CFML Stuffs Me Do

 

Press Ctrl+Enter to quickly submit your post
Quick Reply  
 
 
  
 From:  Peter (BOUGHTONP)  
 To:  Ken (SHIELDSIT)      
38447.41 In reply to 38447.40 
Still don't feel entirely awake, so I might be missing something stupid, but for your main query you don't need GROUP BY unless your SELECT contains an aggregate for that query, which it doesn't.

(Your two aggregates, ConsumedVol and ProducedVol, are both in sub-queries, which would have their own GROUP BY if they needed it, but they don't since they're totals)


For the totalling bit of code... well, when you group on cfoutput you need an inner loop to do the more specific bit - and, more importantly, you need to ORDER BY the grouped bit first, otherwise you tend not to get what you're after.

So try this...
code:
<cfquery name="KilnsById" dbtype="query">
	SELECT *
	FROM Kilns
	ORDER BY ruhId ASC
</cfquery>
 
<cfset TotalTotal = 0 />
<cfoutput query="KilnsById" group="ruhId">
	<cfset InTotal = 0 />
	<cfoutput>
		<cfset InTotal += rudTotal />
	</cfoutput>
	<cfset TotalTotal += InTotal />
</cfloop>



Oh... except InTotal is needed for final table... so you probably actually want this:

code:
<cfquery name="KilnsById" dbtype="query">
	SELECT *
	FROM Kilns
	ORDER BY ruhId ASC
</cfquery>
 
<cfset TotalTotal = 0 />
<cfset InTotal = [] />
<cfoutput query="KilnsById" group="ruhId">
	<cfset InTotal[ruhId] = 0 />
	<cfoutput>
		<cfset InTotal[ruhId] += rudTotal />
	</cfoutput>
	<cfset TotalTotal += InTotal[ruhId] />
</cfloop>


Then do #InTotal[ruhId]# in the final td bit.

Maybe.

I'm not entirely convinced I'm not completely overcomplicating things here. :S
0/0
 Reply   Quote More 

 From:  Ken (SHIELDSIT)   
 To:  Peter (BOUGHTONP)     
38447.42 In reply to 38447.41 
Can you tell me where I want to put that bit of code in my code? I've confused myself!


0/0
 Reply   Quote More 

 From:  Peter (BOUGHTONP)  
 To:  Ken (SHIELDSIT)      
38447.43 In reply to 38447.42 
Replace your current bit of totalling code... everything after the comment saying "set variables for totals" and before the one saying "start the output of table headers".
0/0
 Reply   Quote More 

 From:  Ken (SHIELDSIT)   
 To:  Peter (BOUGHTONP)     
38447.44 In reply to 38447.43 
OK. What about the missing beginning of the loop? I'd guess about where to start it, but I'm sure I'd be wrong.


0/0
 Reply   Quote More 

 From:  Ken (SHIELDSIT)   
 To:  Ken (SHIELDSIT)      
38447.45 In reply to 38447.44 
I ended up getting a book for SRS too because I'm going to need to learn it.

I got this one.

Fuck - Peter this was to you.


0/0
 Reply   Quote More 

 From:  Peter (BOUGHTONP)  
 To:  Ken (SHIELDSIT)      
38447.46 In reply to 38447.44 
Oh bugger! Told you I wasn't awake. That should be a </cfoutput> not a </cfloop>. Like this:

code:
<cfquery name="KilnsById" dbtype="query">
	SELECT *
	FROM Kilns
	ORDER BY ruhId ASC
</cfquery>
 
<cfset TotalTotal = 0 />
<cfset InTotal = [] />
<cfoutput query="KilnsById" group="ruhId">
	<cfset InTotal[ruhId] = 0 />
	<cfoutput>
		<cfset InTotal[ruhId] += rudTotal />
	</cfoutput>
	<cfset TotalTotal += InTotal[ruhId] />
</cfoutput>


(Although, ideally it should all be a cfloop, and whoever at Allaire thought it was a good idea to implement grouping on cfoutput and not on cfloop should be kicked hard.)
0/0
 Reply   Quote More 

 From:  Ken (SHIELDSIT)   
 To:  Peter (BOUGHTONP)     
38447.47 In reply to 38447.46 
OK so I do that and I get this error:

quote:
can't cast [K217] string to a number value


0/0
 Reply   Quote More 

 From:  Peter (BOUGHTONP)  
 To:  Ken (SHIELDSIT)      
38447.48 In reply to 38447.47 
That's because I did another stupid thing, and gave you an array instead of a structure.

Change:
code:
<cfset InTotal = [] />

to:
code:
<cfset InTotal = {} />


Sorry. :(
0/0
 Reply   Quote More 

 From:  Ken (SHIELDSIT)   
 To:  Peter (BOUGHTONP)     
38447.49 In reply to 38447.48 

Not a problem at all. It didn't work, but I'm taking a break and going to look at the SQL Reporting side of it for a bit. It has me confused and I need a break!

 

Thanks for your time!



0/0
 Reply   Quote More 

 From:  Ken (SHIELDSIT)   
 To:  Peter (BOUGHTONP)     
38447.50 In reply to 38447.49 

Paeter most of my issue wasn't coding at all. My database contains both consumed and produced product. I only wanted to add consumed and ignore the produced.

 

Armed with that information I kicked it's ass and now have it adding what I want.

 

Appreciate you taking the time to whisper sweet nothings in my ear!



0/0
 Reply   Quote More 

 From:  Ken (SHIELDSIT)   
 To:  Peter (BOUGHTONP)     
38447.51 In reply to 38447.50 
Well my book came today, and I was able to make a report right off the get go. SQL Server Reporting Services is very similar to CF. There is still a bit of logic I need to figure out, and figure out how to implement it in the SSRS using the right code, but so far so good!


0/0
 Reply   Quote More 

 From:  Ken (SHIELDSIT)   
 To:  Ken (SHIELDSIT)      
38447.52 In reply to 38447.51 

What do you suggest the best way to put this data in to a database so I can use it to compare against another database?

 

I will need to check for type of wood and thickness and then pull that value to multiply by.



Attachments:
ScreenShot001.bmp

0/0
 Reply   Quote More 

 From:  Peter (BOUGHTONP)  
 To:  Ken (SHIELDSIT)      
38447.53 In reply to 38447.52 
Um... interesting question.

Not really sure at the moment - would depend what the data to compare against was like.

If it's just standalone data, I'd probably go ahead with one table:

code:
 
CREATE TABLE wood_costs
( species VARCHAR(30) NOT NULL
, thickness TINYINT NOT NULL
, cost      SMALLINT DEFAULT NULL
);
 
INSERT INTO wood_costs ('Red Oak',3,85);
INSERT INTO wood_costs ('Red Oak',4,85);
...
INSERT INTO wood_costs ('Hard Maple',7,135);
...
INSERT INTO wood_costs ('Other Hardwood',16,285);
 


Then extract distinct species and loop through ordered by thickness for outputting cost.

Though some might argue for three tables (with IDs for species and thickness to avoid duplicating data), but not sure that makes practical sense here.

I'm now a bit paranoid that I'm missing the point entirely in what you're asking, and you actually meant something else? :S
0/0
 Reply   Quote More 

 From:  Ken (SHIELDSIT)   
 To:  Peter (BOUGHTONP)     
38447.54 In reply to 38447.53 
No, you understood it perfectly. And that's what I thinking. Just have to either loop through and compare or compare with the sql statement right?


0/0
 Reply   Quote More 

 From:  Peter (BOUGHTONP)  
 To:  Ken (SHIELDSIT)      
38447.55 In reply to 38447.54 
Probably better to compare actual data than SQL statements.
0/0
 Reply   Quote More 

 From:  Ken (SHIELDSIT)   
 To:  Peter (BOUGHTONP)     
38447.56 In reply to 38447.55 
Sweet. Wish I had the proper ports forwarded on my server so I could show you the report. I might get around to that some day.


0/0
 Reply   Quote More 

 From:  Ken (SHIELDSIT)   
 To:  Peter (BOUGHTONP)     
38447.57 In reply to 38447.56 
How do you center a page in XML? I tried <center></center> and it threw a bitch fit.


0/0
 Reply   Quote More 

 From:  Peter (BOUGHTONP)  
 To:  Ken (SHIELDSIT)      
38447.58 In reply to 38447.57 
Well you don't use <center></center> at all for anything, really, because that's not even real HTML.

And you don't "center a page in XML" because XML, in general, describes data rather than layout/formatting, so doesn't have a concept of centering.

To give you a useful answer, I need more information.

What are you actually using - is it XHTML, is it file.xml with a related file.xslt, or is it something else?

Do you mean center like this:
I am centered text
in a left-aligned box.


Or like this:
I'm a centered box,
with left aligned text
0/0
 Reply   Quote More 

 From:  Ken (SHIELDSIT)   
 To:  Peter (BOUGHTONP)     
38447.59 In reply to 38447.58 
Why are the center tags not proper html?

I'm try to do the 2nd example you posted there.

I have a report made and I would like the whole thing centered on the page.

This is an example of the code that I can see.

code:
<?xml version="1.0" encoding="utf-8"?>
<Report xmlns:rd="http://schemas.microsoft.com/SQLServer/reporting/reportdesigner" xmlns:cl="http://schemas.microsoft.com/sqlserver/reporting/2010/01/componentdefinition" xmlns="http://schemas.microsoft.com/sqlserver/reporting/2010/01/reportdefinition">
  <AutoRefresh>0</AutoRefresh>
  <DataSources>
    <DataSource Name="KilnData">
      <DataSourceReference>KilnData</DataSourceReference>
      <rd:SecurityType>None</rd:SecurityType>
      <rd:DataSourceID>0915e801-0c00-4013-a86a-3762972008de</rd:DataSourceID>
    </DataSource>


0/0
 Reply   Quote More 

 From:  Peter (BOUGHTONP)  
 To:  Ken (SHIELDSIT)      
38447.60 In reply to 38447.59 
Because proper HTML is for describing the meaning, not what it looks like (that's what CSS is for).

If this was anything other than Microsoft, I'd say you have an XSLT file somewhere, which transforms that XML into HTML, and you would just need to locate that file and set the left and right margins to "auto" (and assign a fixed width) and the report would be centered.

(That box above was simply <div style="background-color:silver; width:350px; margin:auto;">I'm a centered box,<br />with left aligned text.</div>)

But - because it's Microsoft - they've probably invented their own way of doing it, just because that's what Microsoft does.

And it looks like they have, with their RDL thing. So what you need to do is read their documentation on Layout / Page and see if you can set LeftMargin and RightMargin to auto, or if you need to calculate explicit values to use.

Didn't you mention you had a book on SSRS? This is probably mentioned in there somewhere.
0/0
 Reply   Quote More 

Reply to All  
 

1–20  21–40  41–60  61–75

Rate my interest:

Adjust text size : Smaller 10 Larger

Beehive Forum 1.5.2 |  FAQ |  Docs |  Support |  Donate! ©2002 - 2024 Project Beehive Forum

Forum Stats