Next Value from Previous Formula
Printed From: Crystal Reports Book
Category: Crystal Reports 9 through 2020
Forum Name: Report Design
Forum Discription: The best way to design a report and problems you have encountered
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=22757
Printed Date: 03 May 2024 at 11:24pm
Topic: Next Value from Previous Formula
Posted By: lgomes
Subject: Next Value from Previous Formula
Date Posted: 10 Apr 2019 at 1:15pm
Hi everyone, I'm having to create a mock crosstab and each "cell" (drawn only) contains a formula.
I would like to create a formula that looks the previous formula to its left either by name or position, and give me the next value from that original formula.
So Formula 1 shows record #128. I want formula two to look at 1 and its 128 and give me #129.
Does that make sense?
Any help is much appreciated.
|
Replies:
Posted By: DBlank
Date Posted: 11 Apr 2019 at 3:27am
what is the formula for 'cell 1'?
|
Posted By: lgomes
Date Posted: 11 Apr 2019 at 4:59am
The formula in cell one just looks to see if the tech selected it as the first cell, and if so - show sample id and sample type.
if {?Starting Cell} = '3-4-A'
then
{ORDTASK.ORDNO} + chr(13) +
{@SpecimenType} + chr(13)
else ""
|
Posted By: DBlank
Date Posted: 11 Apr 2019 at 6:25am
So not really knowing the data I would suggest you think of this in a slightly more simple fashion.
If you can consistently determine a value that is in the "first cell" then second cell should just be that same formula "+1". Don't bother trying to reference the first cell, just use the same formula again with a "+1".
You clearly will need to move from a string to an int to do that but I think logically it is fine.
Again, I don't know your data at all but maybe something like:
if {?Starting Cell} = '3-4-A'
then
tonumber({ORDTASK.ORDNO}) + 1
|
Posted By: lgomes
Date Posted: 11 Apr 2019 at 6:29am
Thank you!
Except that won't work... The Ordno(sample id) is a string so adding the +1 does not give me what I need. It's almost like I need to assign a number value to the ID's and then call those but show what they represent - in my case a string value. This has made my brain hurt for days now and I'm starting to think it can't be done.
|
Posted By: lgomes
Date Posted: 11 Apr 2019 at 6:34am
I also tried using next({ORDTASK.ORDNO}) but that only works on cell two. The following cells just show that second value over and over.
|
Posted By: DBlank
Date Posted: 12 Apr 2019 at 4:56am
if the Ordno(sample id) string is still a number (just stored as a string) then convert it and +1 then convert it back if you need to.
|
Posted By: lgomes
Date Posted: 12 Apr 2019 at 5:03am
Unfortunately, it's alphanumeric with a dash in the middle.
|
Posted By: DBlank
Date Posted: 12 Apr 2019 at 5:53am
parse it, add 1 to the number portion and then concatenate back together
|
Posted By: lgomes
Date Posted: 12 Apr 2019 at 5:55am
hmmmm, that might just work! I'll try it. Thank you
|
|