I'm working with iReport 2.0.5 (because I have to) and I have a little issue formatting percentages.
When I use an unformatted double this is what I get:
0
22,22
5,555 (this is the average of the whole group)
100
100 (this is the average of the whole group)
The average is calculated OK
But when I set the pattern #,##0.00 % using iReport 2.0.5 this happens:
0,00 %
2.222,00 %
555,50 % (this is the average of the whole group)
10.000,00 %
10.000,00 % (this is the average of the whole group)
How do I stop the values from changing?
What you can also do, without changing (dividing) your value:
Try this pattern:
#,##0.00 ' %'
when you put % in quotes ( '%' ), then your value will not be multiplied with 100.
Cheers!
22,22 is 2.222,00 % what you need is 0.2222 so this is a solution (just dived by 100)
In old version expression it is achieved like this:
new Double($F{percentageVar}.doubleValue()/100d)
So your textField (hoping that $F{percentageVar} is never null) is
<textField isStretchWithOverflow="true" pattern="#,##0.00 %" isBlankWhenNull="false" evaluationTime="Now" hyperlinkType="None" hyperlinkTarget="Self" > <reportElement x="694" y="0" width="88" height="20" key="textField-8"/> <box></box> <textElement textAlignment="Right" verticalAlignment="Middle"> <font/> </textElement> <textFieldExpression class="java.lang.Double"><![CDATA[new Double($F{percentageVar}.doubleValue()/100d)]]></textFieldExpression> </textField>
Related
I have a list like this: (it will generated by a for loop, and each row is related to a unique ref : ref="'dataRow'+id" )
<GridLayout class="mainList">
<ListView
for="( sentence , id ) in sentences"
><v-template><StackLayout>
<GridLayout
class="dataRow"
:ref="'dataRow'+id"
#tap="tapAction( 'dataRow'+id )"
>
...
</GridLayout>
</StackLayout></v-template></ListView>
</GridLayout>
I would like to expand each row of Data by tapping on it, and I acheive that by this piece of the code:
tapAction ( dR ) {
this.$refs[dR].nativeView.animate ( {
height: 300 ,
duration: 200 ,
curve: enums.AnimationCurve.easeIn
} )
}
(BTW I noticed it expands multiple rows!! I think it is related to the nature of ListView but it seems a bit bizarre to me while I used unique ref for each row of data! any suggestion for this issue would be helpful, but my actual question is something else.)
my problem is this:
I woud like to collapse all expanded rows at once , but I can Not find a proper way to do that! my first thought was that to set all elements by the dataRow calssName to the default value, but I can Not do that as simple as we can perform in a web browser with css + js.
So I have this query to get the results from my database tables with the columns in and out.
<cfquery name="getInfo" datasource="testing">
select in, out from test
</cfquery>
Now what I need to do is to take a static number, eg; 100, and ADD the in and SUBTRACT the out from that static number.
So this is what I tried:
<cfquery name="getInfo" datasource="testing">
select in, out from test
</cfquery>
<table>
<cfset balance = 100>
<cfloop query="getInfo">
<cfset balance = balance + in - out> <!--- THIS IS WHAT I TRIED --->
<tr>
<td>#in#</td>
<td>#out#</td>
<td>#balance#</td>
</tr>
</cfloop>
</table>
So as you can see, I did set this code <cfset balance = 100 + in - out>. Basically what I am trying to do is to get the original value of balance which is 100 and add the values of in and subtract the value of out and save it as the new balance.
However, I am getting an error saying The value '' cannot be converted to a number..
I have set the values for in and out to be float in the database.
Where am I going wrong?
You need to update your query to cover NULL conditions
<cfquery name="getInfo" datasource="testing">
select ISNULL([in], 0) AS [in], ISNULL([out], 0) AS [out]
FROM test
</cfquery>
Also I put square brackets around in and out because they look like they might be key words
Also consider doing the math on the DB, you might get better performance
I want to find all position of 'LIID' string into 'DATASTRING' column using which help to find all LLID values.
DATASTRING Column contains MIXED data its not valid XML file.
Query :
select id , DATASTRING from mixdatatable
Output :
id DATASTRING
1 ABC XYZ IS 1 ..
<ObjectValue /><CP /><SIProps ST="4" PL="False" PLS="" />
<STI_SummaryActiveProblemsField LIID="cdbd7044-ccde-11db-8cba-df0a56d89593" IID="37742a5f-7998-4715-8d43-0d7a19284d44" IR="True" RW="1">
<HD Title="Active Problems" /><ObjectValue />
<CP><PosReplace /><NegReplace /></CP><SIProps ST="4" PL="False" PLS="" />
-<STI_DxItem IID="d85c91e7-703f-4f8c-9a38-961fb2d14828" RW="1" LIID="03e4da86-d57c-408e-9479-b6fb97cc9a60"><HD Title=" unspecified "/>
<STI_US><ObjectValue><TextValue><![CDATA[
]]></TextValue></ObjectValue><CP />
<LIID='71194038-8ffb-488b-8af5-5f1f1a679115'>
<SIProps ST="1" SS=" " PL="False" PLS="" />
</STI_US> AAAAAA
979816816/881783683618317381-817
I want to find all LIID values. LLID values lenth are '36' eg.'cdbd7044-ccde-11db-8cba-df0a56d89593'
Expected Output :
ID LLID
1 cdbd7044-ccde-11db-8cba-df0a56d89593
1 03e4da86-d57c-408e-9479-b6fb97cc9a60
1 71194038-8ffb-488b-8af5-5f1f1a679115
PostgreSQL version 8.3
Note : i dont have acess to create function or procedure.
select id, unnest(regexp_matches(datastring,'LIID=[''"]([0-9a-f-]+)','g'))
from mixdatatable
Test on sqlfiddle.com
I'm trying to display the results of a query, but I'm having a hard time combining two values that the query produces... Here's the query I have
<cffunction name="getStudentData" returntype="query">
<cfargument name="nameVar" type="string" required="yes">
<cfargument name="timeframe" type="numeric" required="yes">
<cfquery datasource="#Application.hds#" name="gsd">
select (s.lastname + ', ' + s.firstname) as StudData,
('[' + r.hallname + ' ' + r.roomnumber + ']') as roomdata,
s.studentnumber
from tblstudents s left join
(select h.hallname, ra.roomnumber, studentid
from tblroomassignments ra, tblhalls h
where ra.TimeFrame = #Arguments.timeframe#
and ra.hallid = h.hallid) r
on s.studentid = r.studentid
where s.lastname like '#Arguments.nameVar#%'
</cfquery>
<cfreturn #gsd#>
</cffunction>
What I'm trying to figure out is how to display StudData+' '+roomdata IF they both exist together since some students won't have a room assigned to them. (I'm just trying to produce a list of students that have a dorm/room assigned to them. In my cfselect...
<cfselect name="RecipientName"
query="studentdata"
display="StudData+' '+roomdata"???????
value="studentnumber">
</cfselect>
I don't know how to get StudData and roomdata in the display attribute without the page giving me an query column error. I'm very new to coldfusion and it's my understanding that you can only display one variable? Is there a way to combine StudData and roomdata into a variable and then display that variable?
Anyone have any ideas? Could this be simplified?
Hope this all makes sense!
I wouldn't use a cfselect at all.
<select name="RecipientName">
<cfoutput query="studentdata">
<option value="#studentnumber#">#StudData# #roomdata#</option>
</cfoutput>
</select>
If you really want to use cfselect, then I'd concatenate the columns in your query.
StudData + roomdata AS expanded_student_data
...
<cfselect name="RecipientName"
query="studentdata"
display="expanded_student_data"
value="studentnumber"
>
</cfselect>
I have a visual studio report that I want to state that if a calculation box is blank due to there being no figures available on that particluar project then show zero.
My calculation is :- =((Sum(Fields!TotalCost.Value, "Accrued") + Sum(Fields!TotalCost.Value, "serv1")) /
(Sum(Fields!Quantity.Value, "serv1") + Sum(Fields!Quantity.Value, "Accrued"))
)
And I want to try and include an IIF statement in that to show zero if blank.
Any ideas on how to best achieve my aim?
so far I have got to
=iif((Sum(Fields!TotalCost.Value, "Accrued") + Sum(Fields!TotalCost.Value, "serv1")) /
(Sum(Fields!Quantity.Value, "serv1") + Sum(Fields!Quantity.Value, "Accrued"))
) = "" ,false,0 ) but I am getting a little confused.
Most likely value is not blank string but a Nothing. Try following construct:
=IIf(IsNothing(((Sum(Fields!TotalCost.Value, "Accrued") + Sum(Fields!TotalCost.Value, "serv1")) / (Sum(Fields!Quantity.Value, "serv1") + Sum(Fields!Quantity.Value, "Accrued"))), 0, ((Sum(Fields!TotalCost.Value, "Accrued") + Sum(Fields!TotalCost.Value, "serv1")) / (Sum(Fields!Quantity.Value, "serv1") + Sum(Fields!Quantity.Value, "Accrued")))
It's a bit awkward since you have to repeat the expression twice, to avoid it you may want to write a custom function.