Formula
-
- Posts: 50
- Joined: Mon Mar 26, 2007 6:32 pm
- Location: Malaysia
Formula
Hi. I am trying to migrate from crystal report to stimulReport. I wonder how to Add a formula field? The reason is I want to sum up all the total for a column Call Total Work Hour as shown below
Name Total Work Hour
Billy 3:33
Jasicca 12:33
Daniel 12:00
Total 28:06
As shown above. The total cannot be using the Sum function. I have to write my own formula in order to sum the hour which is in string format. Last time i was using crystal report formula fields to settle the problem, but i have no idea how the stimulReport formula fields work.
Hope can get help from the expert. Thanks
Name Total Work Hour
Billy 3:33
Jasicca 12:33
Daniel 12:00
Total 28:06
As shown above. The total cannot be using the Sum function. I have to write my own formula in order to sum the hour which is in string format. Last time i was using crystal report formula fields to settle the problem, but i have no idea how the stimulReport formula fields work.
Hope can get help from the expert. Thanks
Formula
You can do following steps:
1. Add variable to report dictionary which will be store result of calculating.
2. In Rendering event of DataBand place code for calculating total. For example:
3. At footer band (or in any other component) place textbox. Set property ProcessAtEnd of this textbox to true. Type in text expression:
Thank you.
1. Add variable to report dictionary which will be store result of calculating.
2. In Rendering event of DataBand place code for calculating total. For example:
Code: Select all
variable += value;
Code: Select all
{variable}
-
- Posts: 50
- Joined: Mon Mar 26, 2007 6:32 pm
- Location: Malaysia
Formula
Hi Vital,
Thanks for your reply. The problem now is i need to use some expression. As I shown you before. The value are all time, they are string in my system. I need to split them to hour and minutes using delimeter ":". sum up all hour and minutes seprately. Then convert minute to hour. Then only possible to get the total.
For the case i quoted before,
Total hour = 3 + 12 + 12 = 27
Total Minute = 33 + 33 = 66
Final Total Hour = 27 + (66 / 60) = 28
Final Total Minute = 66 - 60 = 6
Final Result will be 28:06
As you may see. i need to split using the time by ":" first before i can sum them up. I just wonder is it possible to do my own formula like crytal report.
Thanks for help
Thanks for your reply. The problem now is i need to use some expression. As I shown you before. The value are all time, they are string in my system. I need to split them to hour and minutes using delimeter ":". sum up all hour and minutes seprately. Then convert minute to hour. Then only possible to get the total.
For the case i quoted before,
Total hour = 3 + 12 + 12 = 27
Total Minute = 33 + 33 = 66
Final Total Hour = 27 + (66 / 60) = 28
Final Total Minute = 66 - 60 = 6
Final Result will be 28:06
As you may see. i need to split using the time by ":" first before i can sum them up. I just wonder is it possible to do my own formula like crytal report.
Thanks for help
Vital wrote:You can do following steps:
1. Add variable to report dictionary which will be store result of calculating.
2. In Rendering event of DataBand place code for calculating total. For example:
3. At footer band (or in any other component) place textbox. Set property ProcessAtEnd of this textbox to true. Type in text expression:Code: Select all
variable += value;
Thank you.Code: Select all
{variable}
Formula
Yes it is possible to sum up the values in the format of the DateTime. For this instead of the
expression, please write the following:
variable must be declared as DateTime type.
The expression in the textbox from Vital's answer also may be represented as required. For this just right-click the textbox and setup the format you need.
There is another way to achieve the goal is Calculated Columns which is similar to Formula Fields in Crystal Reports. The following flashing tutorial will help you to start work with this columns:
http://www.stimulsoft.com/livedemos/Rep ... ields.html
Thank you.
Code: Select all
variable += value;
Code: Select all
variable = variable.AddHours(variable.Hour).AddMinutes(variable.Minute);
The expression in the textbox from Vital's answer also may be represented as required. For this just right-click the textbox and setup the format you need.
There is another way to achieve the goal is Calculated Columns which is similar to Formula Fields in Crystal Reports. The following flashing tutorial will help you to start work with this columns:
http://www.stimulsoft.com/livedemos/Rep ... ields.html
Thank you.
-
- Posts: 50
- Joined: Mon Mar 26, 2007 6:32 pm
- Location: Malaysia
Formula
Hi Edward,
I can't declare as DateTime type, because the total might be 123:45 which means total working time is 123 hours 45 minutes. Hence i store the time in string type, besides, i also store the time in minute as (123 * 60) + 45 = 7425 minutes. Do you think is it possible to sum the minute first then convert it to time? Is stimul report have something like formula where i can write my own formula probably based on c# or vb script like crystal report?
Besides, is there any help file for formula so that i can refer to?
Thanks again for help.
I can't declare as DateTime type, because the total might be 123:45 which means total working time is 123 hours 45 minutes. Hence i store the time in string type, besides, i also store the time in minute as (123 * 60) + 45 = 7425 minutes. Do you think is it possible to sum the minute first then convert it to time? Is stimul report have something like formula where i can write my own formula probably based on c# or vb script like crystal report?
Besides, is there any help file for formula so that i can refer to?
Thanks again for help.
Edward wrote:Yes it is possible to sum up the values in the format of the DateTime. For this instead of the
expression, please write the following:Code: Select all
variable += value;
variable must be declared as DateTime type.Code: Select all
variable = variable.AddHours(variable.Hour).AddMinutes(variable.Minute);
The expression in the textbox from Vital's answer also may be represented as required. For this just right-click the textbox and setup the format you need.
There is another way to achieve the goal is Calculated Columns which is similar to Formula Fields in Crystal Reports. The following flashing tutorial will help you to start work with this columns:
http://www.stimulsoft.com/livedemos/Rep ... ields.html
Thank you.
Formula
You write write your own class in an external library (.dll) and use that in Stimulsoft. Everything that is .net can be used.
Marco
Marco
-
- Posts: 50
- Joined: Mon Mar 26, 2007 6:32 pm
- Location: Malaysia
Formula
Thanks Marco. i will try it out.
EDV wrote:You write write your own class in an external library (.dll) and use that in Stimulsoft. Everything that is .net can be used.
Marco