computing the difference of a column in the current row from the column of the preceding row

Hello,

a user asked me if we can solve following problem:

we want to compute the difference (delta) of a column in the current row
from the column of the preceding row.
My first solution signs where:
create a computed field (small_function_result) that takes the value from
the preceding row:
small(value, value, cf_getrow for all); where cf_getrow is a computed field
like this:
if(getrow()=1,getrow(),getrow()-1)

create a computed field (Diff) that computes the difference:
value-small_function_result

My results should look like this:
Row    Value        cf_getrow  small_function_result  Diff
1          5123         1                 5123                             0
2          5126         1                 5123                             3
3          5132         2                 5126                             6
4          5134         3                 5132                             2
and so on

But it seems that the small-function doesn't work dynamically, because i got
following result (the difference
is an cumulative value) (the computed field cf_getrow contain the right
values !!!!!):
Row    Value        cf_getrow  small_function_result    Diff
1          5123        1                  0
0
2          5126        1                  5123
3
3          5132        2                  5123
9
4          5134        3                  5123
11
and so on

Has anybody some ideas ?

Thanks

Michael




0
Michael
11/4/1999 12:54:06 PM
sybase.infomaker.general 4461 articles. 0 followers. Follow

1 Replies
733 Views

Similar Articles

[PageSpeed] 28

refer to previous threads of "counter problems" and "Calculations on different
rows" where Terry describes th [-1] option

Just a thought

Michael Huber wrote:

> Hello,
>
> a user asked me if we can solve following problem:
>
> we want to compute the difference (delta) of a column in the current row
> from the column of the preceding row.
> My first solution signs where:
> create a computed field (small_function_result) that takes the value from
> the preceding row:
> small(value, value, cf_getrow for all); where cf_getrow is a computed field
> like this:
> if(getrow()=1,getrow(),getrow()-1)
>
> create a computed field (Diff) that computes the difference:
> value-small_function_result
>
> My results should look like this:
> Row    Value        cf_getrow  small_function_result  Diff
> 1          5123         1                 5123                             0
> 2          5126         1                 5123                             3
> 3          5132         2                 5126                             6
> 4          5134         3                 5132                             2
> and so on
>
> But it seems that the small-function doesn't work dynamically, because i got
> following result (the difference
> is an cumulative value) (the computed field cf_getrow contain the right
> values !!!!!):
> Row    Value        cf_getrow  small_function_result    Diff
> 1          5123        1                  0
> 0
> 2          5126        1                  5123
> 3
> 3          5132        2                  5123
> 9
> 4          5134        3                  5123
> 11
> and so on
>
> Has anybody some ideas ?
>
> Thanks
>
> Michael

--
================================================
Stephen Kelly
Consultant
Pro Management Systems, Inc.
PO Box 4542
Salem, OR 97302
--------------------------------
http://www.promanagementsystems.com
steve@promanagementsystems.com
phone 503.362.2256
fax  503.585.7697
================================================
Certified Trainer of Expedition by Primavera
Certified Trainer of Infomaker for Expedition

Primavera ... The Leader in Contract Management
================================================


0
Steve
11/4/1999 5:36:50 PM
Reply:

Similar Artilces:

How to go through a datatable row by row and column by column
Hello, I have a dataset with a datatable and I need to insert each row from the datatable on my sql table, anyway there may be errors, so some rows may not be inserted because primary key constraints,  So I need to show the rows that are not inserted in a gridview, the hard thing to do is to go through all the datatable,  is there an wasy way to do it?MCPD ENTERPRISE APPLICATION DEVELOPER Start by looking herehttp://msdn2.microsoft.com/en-us/library/system.data.common.dataadapter.update.aspxPerform an update of your dataset, and if a row fails, you can mark it as invalid.You can ...

GridView.Rows(Column=ID_PK) to GridView.Rows(Column=DropDownListTeamplteField)
Hi Guys,I wonder how I can assign the PrimaryKey in each GridView Row to the template field in the same row. whereas the template field is filled with a dropdownlist thatshould show the values for retrieved in a different table through the GridView Row primary key (which serves as the SELECT parameter to get these values) The GridView looks like this:<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="C_ID" DataSourceID="GetC_IDs"> <Columns> <asp:BoundField D...

SQL: mutiple rows one column to multiple columns one row
In InfoMaker SQL can you take a table with multiple rows for the same key and take a column from the rows and create mutiple columns with one report line with the key(no duplicate keys) on a report? For example Table books (key) (book title) 123 misery 123 titanic 123 roots 456 war 456 1984 456 giant The report I need would look like this Key title1 title2 title 3 123 misery titanic roots 456 war 1984 giant Thanks in advance. -- Kaye Hendry HealthInsight email:kaye.hendry@healthinsight.org ...

Using the column value of another row in computed column.
Hi fellow PBer's, I am having trouble figuring out how to reference the column value of a specific row. In the computed columns property sheet, I select the "More" button to modify the columns expression. The way I understand help is to specify columnname[integer] where integer is the number of rows (positive or negative) relative to the current row (ie Total[-1] would be the value of the Total column in the previous row. However, I cant seem to get this to compile in the modify expression painter. I am using PB5.0 on Win95. Any help would be greatly appreciated. ...

How to divide 1 GridView Row with 1 column in 2 Rows with 5 columns?
Hi; I have a GridView with 10 rows and 1 column. How can I do to this GridView show the same data, but with 2 rows and 5 columns? In classic ASP, I made it this way: While (NOT rsFotos.EOF) if i mod 5 = 0 then Response.Write "</tr><tr>" end if ... Someone can help? :)  You have to use a custom template and lay the table out the way you want, either dropping controls in the template or creating a custom ITemplate that takes care of it for you. http://professionalaspnet.com/archive/2006/06/15/Useing-ITemplate-in-the-Data-Controls.aspxChris L...

How can I display multiple rows w/8 columns (4 columns editable on each row)?
Hello, Please - Can anyone suggest the best way to display a joined dataset with 4 read-only columns, 4 editable columns and a checkbox column? The content for this display currently has < 100 rows - but could approach 1000 in the future. I currently have this setup with a Datagrid (working) - but I would like to be able to edit the 4 columns of ALL rows in the displayed list instead of one row at a time as the Datagrid allows. After editing, I use an update function to traverse the modified list/table and save all values that have the Checkbox clicked. Could a list with 10...

is it possible to turn 1 column,many rows into one row,many columns in sql ?
 Hi AllI have the following query:Select CategoryName From Category Where CategoryId In(Select SkillId From SpecialitySkills Where CopywriterId = 13) It gives me the correct results but not in the form that i want, i would like it to be in one row, many columns. its in 1 column, many rows.Any ideas?  You must be talking about displaying it on a web page? Just create a loop that runs through the rows of the data that is returned then just make html table:dim tablestring as string = "<table><tr>" for i as integer = 0 to dt.rows.count - 1 tablestring += &...

Calculated column from columns in same row??
Hi everyone - Is there a way to display a calculated value in a column based on values from the same row? Using a datagrid thanks tony Sure. Have a function declared for your OnItemDataBound: Sub CalculateValues(ByVal sender As Object, ByVal e As DataGridItemEventArgs) dim total as Integer = CType(e.Item.FindControl("col1"), Integer) + CType(e.Item.FindControl("col2"), Integer) e.Item.FindControl("totalCOlumn").Text = total End Sub I think it would be something like that.Sarahttp://www.ilovecode.com If yo...

Arranging data on multiple rows into a sigle row (converting rows into columns)
Hello, I have a survey (30 questions) application in a SQL server db. The application uses several relational tables. The results are arranged so that each answer is on a seperate row: user1   answer1user1   answer2user1   answer3user2   answer1user2   answer2user2   answer3 For statistical analysis I need to transfer the results to an Excel spreadsheet (for later use in SPSS). In the spreadsheet I need the results to appear so that each user will be on a single row with all of that user's answers on...

how to display result of different year in different column instead of different row?
I am trying to display component usage in January for the past year, if I want to display the year in different column, what should I do? eg. component_id   component_description   qty_used_on_2005_Jan   qty_used_on_2006_Jan C58B0BDD       tape drive                             2               ...

Avergae of Current Row and Preceding Row
Hi I am trying to get calcualtion using MS Access query, Average of current row and preceding row. e.g i have three columns YEAR,MONTH, SALARY                                       2000      01        1000                       &nbs...

How to display different data in different columns instead of rows?
Hi All, My requirement is to display different data in different columns instead of rows. For example : I have database wih one table "Contact"(columns: Name, address, phoneno) with 10 data in it. If I will take gridview to display "Contact" data, It will display in 10 different rows. But my requirement is like... I have to creat mailing labels using this data. Means I am in need of a control or method to display different data entity in different columns instead of rows like... (suppose I want 4 columns than it will look like) Column1   &nb...

How to update columns from row to another row? (thank you)
 assume my Table's Columns looks like below1  ,   Annie,   History, pass, null 2  ,   Colin,   Math   , Pass, null7  ,   Annie,   History, Fail, 111 ,   Colin,   Math   , Fail, 2When Delete 7  ,   Annie,   History, Fail, 111 ,   Colin,   Math   , Fail, 2using the last column to check which row is reference with itso when delete Row 7 which reference with 1  ,   Annie,   History, pass, null w...

Adding a row to the last row column in Gridview ?
Hello, I have a gridview and it displays data in row column and I want to add a row across in the bottom of the last row for the total value.  How do I do it?  Thanks Here is my Gridview <Columns> <asp:BoundField DataField="Information" HeaderText="Information" SortExpression="Information" HeaderStyle-Width = "600" HeaderStyle-Wrap = "true"/> </Columns>   use footer? something like maybe.    use TemplateField   <Columns> <asp:BoundField DataField="Infor...

Web resources about - computing the difference of a column in the current row from the column of the preceding row - sybase.infomaker.general

Difference - Wikipedia, the free encyclopedia
Text is available under the Creative Commons Attribution-ShareAlike License ;additional terms may apply. By using this site, you agree to the ...

3Q EARNINGS: Mark Zuckerberg on the Differences Between Messenger and WhatsApp
When Facebook announced its intent to acquire cross-platform messaging application WhatsApp in February, questions surfaced on whether WhatsApp ...

Facebook Tips: What’s the Difference between Top News and Most Recent?
The following is part of our series, Facebook Tips, which answers some of the most commonly asked questions about using Facebook. While we hope ...

Belgium cats, raids and religious differences explained by a Belgian
Belgium police joined the cat fun at the end of a tense day of anti-terror raids and arrests in Brussels.

The West should let the Middle East settle its own differences
The bitter truth is there is no plausible way we can defeat jihadists with military force.

6 Ways To Tell The Difference Between A Terrorist And A Refugee
If you are sitting at the table for five minutes and you can't spot the difference between the refugee and the terrorist, you are the terrorist. ...

Can the US and China transcend their differences?
Why Washington should embrace Beijing’s “new type of major-power relationship”

"There’s been a lot of poorly thought-out stuff written about the differences between men’s and women’s ...
... But if you can get past all of this pseudoscience, there’s some legitimately illuminating, serious medical research on sex-based brain differences ...

Slant wants to transform online media by paying writers 70% of ad revenue — but will that make a difference ...
When Amanda Gutterman talks about her vision for Slant , a platform-publisher hybrid that "soft launched" in July, you can tell she believes ...

Anonymous just might make all the difference in attacking ISIS
In the wake of the horrific attacks in Paris, military operations against ISIS terrorist strongholds have increased. When someone hits you, it’s ...

Resources last updated: 11/30/2015 12:05:33 AM