Previous function, but for two (or more) rows previous - crystal-reports

I'd like to get the value of a cell, two rows previous, is that possible?
I know I can do the row previous, but I'd like two (or more) rows previous
Previous({myTable.myColumn})

Not with any standard functionality that I'm aware of.
Off the top of my head, though, you could try shared variables.
For example, you could have PrevRecord1 and PrevRecord2 variables. A function that is in the detail row of the report would then update PrevRecord2 with PrevRecord1, and then update PrevRecord1 with Previous({myTable.myColumn}).
The obvious downside to this solution is you'll need a variable for each row you want to go back.

Per answer on crystalreportsbook.com
Crystal is limited to only one record previous and one record after (next).

Related

Multiple copies of a record based on formula

Good afternoon,
I am very new to Crystal Reports, so am not sure where to look for this information and would appreciate if someone can point me in the right direction or tell me if what I am asking for is impossible.
One of our departments uses a field called RecordChanges to note changes made to a record. The field is text and the department stores information there about the date a change is made and the type of change, separated by commas (i know this is terribly inefficient, but it's what I have to work with). I have a Crystal Report that parses this text field and picks up the latest date and latest change made to the record. I would like to modify this report to include ALL the changes made to the record, so if the field RecordChanges of the data source has 3 dates, I would like this record to appear in my Crystal Report 3 times, once for each change that was made. How to parse the field I can figure out but where I'm stuck is how do I make the number of times a record appears equal to the number of dates found which is my {#DateFound} field?
There is a lack of details, but as far as I understood the problem and assuming that you did state in the comment that "there wouldn't ever be more than 5 changes to an order", here is a first try to tackle the situation.
I will assume that you already have a formula that "parses this text field and picks up the latest date and latest change made to the record". And that you know how to adjust this formula to pick up each of the record changes. I will name this formula as {#Parser1}.
Based on {#Parser1}, create other 4 formulas: {#Parser2}, {#Parser3}, {#Parser4}, {#Parser5}. As you probably presume, each formula must be changed to parser the Nth occurrence of the record change.
Create 5 details sections.
Put each formula in each detail section.
Suppress the detail section wich formula is null or empty.
That's it.
The limitation is that you can have at most 5 record changes.
This is an awkward solution, but it is necessary (as far as I know) since Crystal Reports works based on your data rows. It iterates over the rows, but cannot "generate" more rows by itself. If you can manipulate the data source, you can create other solutions.
You still need to do the magic trick to pickup the Nth change from the text.

Different sheet references in an "OFFSET(INDIRECT(ADDRESS(MATCH))) array for a Vlookup

I have two worksheets, called "Holdings" (main one) and "Prove" (second one).
I am currently experiencing an issue with a Vlookup with a variable array.
I have a variable data set, which can freely expand rows-wise, but keeps a standard layout columns-wise.
In order to tell the vlookup which values to fetch from the table, I wrote down their list, next to the vlookup formula.
I am able to fetch the correct values if I apply the formula in the main sheet, but when I type it in the second one, adding "Holdings!" before references, it turns out #N/D.
Can someone please help me?

How to get the sum directly with one number?

I'm a beginner for tableau. I want to get the direct numbers for each row, but i get the number which are separate, how can i achieve this?
I've tried the sentence like:count("Implemented"), but I don't get the result I want.
For example, for the 1st row I want 3 10 10
not 111 10 112111111
Here is worksheet.
My code:
EDIT :
here is the photo for implementation opportunities
As you can see, the status is related to the date, I think maybe it causes the records which are counted 1by1.
Now the situation is that: i create the code which is related to the date, if i remove this from mark, it will cause the problem (the code is related to the date), but if i leave it, the system will always count it one by one. My code is not perfect but i can't find another one which can replace it.....
EDIT 2:
in short,what i want is the sum of the remaining opportunity:10
capture
Remove DAY from Mark shelf. That detail is producing those separations.
Attaching a workbook with numbers similar to (but not exact due to proprietary issues) is almost always advised. You will get the right answer a lot sooner than just screenshots.
In any case, it seems as if the measure portion of the visualization is properly being summed by the date. Try selecting the measure, and manually selecting "sum" from the menu drop down. Here is a link for more detail.
Secondly, you can play around with table calculations. Click this link and read up on option 3.

How to return a cell value if the date in a range of cells is today in google sheets

I currently have a Google Sheet, with numerous sheets in it, to track contract deadlines for different clients. One of these sheets shows me all of the deadlines in Columns E:M for every contract. Each row is a separate contract.
I'm trying to create a separate sheet that will show me the client's name, found in column A, if a date in columns E:M is Today. That way I can look at one page and see all the clients that have a deadline today. Here is what I tried with no success:
=if('U/C(Dont Edit)'E2:M2=TODAY(),'U/C(Dont Edit)'A2,"")
"U/C(Dont Edit)" is the sheet that shows all of the contracts.
I believe the problem lies when I try to apply "=Today()" to a range(E:M). It seems to work fine if I just use E2=Today(). It looks like I could accomplish my goal using If statements within If statements, but that gets very messy very quickly and I'm hoping there is a better way.
Thanks in advance for your help.
You can do it with the COUNTIF() function per row:
=IF(COUNTIF(E2:M2,TODAY())>0,A2,"")
But I think a better solution is to use the FILTER() function. It will give you a list of names:
=FILTER(A2:A,(E2:E=TODAY())+(F2:F=TODAY())+(G2:G=TODAY())+(H2:H=TODAY())+
(I2:I=TODAY())+(J2:J=TODAY())+(K2:K=TODAY())+(L2:L=TODAY())+(M2:M=TODAY()))
I suggest #dePatinkin's solution (for and additional column, say N, containing the COUNTIF formula from Row2 downwards) in combination with a query (in another sheet):
=query('U/C(Dont Edit)'!A:N,"select * where N is not NULL")
This assumes your existing sheet has the columns labelled.
You might combine the above with Conditional formatting to indicate which column has the date in it (today) that triggered the row selection.

db2: select from table without replacement

Hi I would just like to ask a simple question - is there a way in DB2, to select a row from a table (whether that be based on a join or selecting a random row), and then select from the same table again where choosing the last, or any previous rows cannot be selected.
I am thinking I have to loop my code through each row in the table and delete each row I select, but would be interested if anyone has an alternative solution. No code needed but rather describe another approach.
Thanks,
Arron
The simplest way of doing this is to declare a cursor to select all rows from the table then process the
cursor one row at a time. Each row will be selected exactly 1 time (this is pretty much what a cursor is all about).
I suspect that is not the answer you were looking for. You most likely have at least two other constrains on this
selection problem:
You do not want, or cannot, have a single cursor open until the entire table has been processed
You want to have some sort of "randomness" with respect to the order in which rows are selected
The problem of not being able to open and process the entire table under a single cursor can be solved by
maintaining some sort of "state" information between selections. The "state" can be used to determine whether a row
is still eligible for selection on subsequent inquiries. You might add another column to the table to hold the "selected"
state of that row. When a row is inserted its "selected" state is set to "no". On each select operation the state
of the selected row is updated to "yes". The predicate to select new rows then needs to have a WHEN SELECT_STATE = 'no'
added to it to disqualify previously selected rows. If you cannot change the structure of the table you are selecting
from, then add a second table having the same primary key as the selection table plus the "selected" indicator then join
these tables to obtain the required state information.
Another approach is to delete a row once it has been selected.
These or some similar type of state management can be used to solve the selection eligibility problem.
If you need to introduce randomness into the selection process (i.e. make it difficult go guess what
the next row to be selected will be), then you have a very different problem to solve. If this is the case
please ask a new question outlining the approximate size of you table (how many rows) and what the key structure
is (eg. a number between 1 and 100000, a 30 character name etc.)
You can use a cursor, and use the 'delete where current of' feature called positioned-delete. For more information:
http://pic.dhe.ibm.com/infocenter/db2luw/v10r5/topic/com.ibm.db2.luw.sql.ref.doc/doc/r0000939.html
http://mysite.verizon.net/Graeme_Birchall/cookbook/DB2V97CK.PDF page 55