Crystal Report Loop until True and Return Value - crystal-reports-2011

I have a field called "Step Number" and would like to determine the previous step. There are two tables: Work Order Step (WOS) & Route Steps (RS).
I would like to state something along these lines:
Take the "Step Number" and subtract 1.
Continue subtracting 1 until the Step Number from WOS is equal to a value in RS
Return the value which stopped the formula
Code I have tried:
do ToNumber({WO3_WorkOrderOperationDetail.StepNumber})-1 while Not(ToNumber({WO3_WorkOrderOperationDetail.StepNumber})= ToNumber({WO_97_UDF_WORoutingLines.StepNumber}))
Also have tried to do a "result" at the end, but this is not my forte and I'm not sure what to do.

Related

power query to return true / false if multiple columns are either = or null

Here's what I am trying to do.
I need a query to figure out if a worker has moved state in the last month.
the columns I'm working with show state as a 2-digit EX: TX
the provincial move data all show in 1 column formatted as seen below:
I've tried separating the 1 column by delimiter which would give as many new columns as there are delimiters.
then tried inserting a custom column to return (true/false) if there were any changes, but no luck...
what I'd be looking for is a simple power query code that would return any and all changes as true per the example below:
if there were any changes to the 2-digit state code, it should return "True". and "False" only if there were no changes to the 2-digit state codes.
In powerquery, add column, custom column with formula
= try if List.Count(List.Distinct(Text.Split([YourColumnNameHere]," > "))) =1 then false else true otherwise true
In excel, something like this, which someone will add a more compact version of
=IFERROR(NOT(SUBSTITUTE(SUBSTITUTE(A1," > ",",")&",",LEFT(SUBSTITUTE(A1," > ",",")&",",FIND(",",SUBSTITUTE(A1," > ",","))),"")=""),TRUE)

IF Statments in EXCEL

I am trying to calculate different price decreases when each statement is true for example
Statement 1 - Y
Statement 2 - N
Statement 3 - N
Statement 4 - N
I have been able to get it to work with one of the statements being true using
=IF(EXACT(L9,"Y"),I29-I9*C21,I29)
However, I don't know how I would be able to add that together if all 4 of the statements were Y as each of the statements is taking away different amounts of money if True.
My guess for it was
=IF(EXACT(L9,"Y"),I29-I9*C21,I29,IF(EXACT(L8,"Y"),I32-I8*C20,I32))
however, to many arguments were being made for the function
any help would be much apricated :)
This is what my excel document looks like at the moment. Don't think I did very well trying to explain it :/.
Excel Document
So more or less what I have been trying to do is when bought is changed to Y it would change that total however I've only been able to find out how to do it with one statement which has been changed to Y using:
=IF(EXACT(J6,"Y"),H18-H6*I6,H18)
sorry for the lack of being to explain much :/
This is how you can build more complex logical functions with IF statements.
If all four statements equal "Y"....
=if(and(A1="Y",B1="Y",C1="Y",D1="Y"),[Calculation if True],[Calculation if False])
So, here is an example of multiple tests nested in a statement.
Test 1: Are all 4 cells equal to "Y"?
If yes, then "Test 1 equals True".
If not,
Test 2: Are the first 3 cells equal to "Y" and the 4th cell equal "N"?
If yes, then "Test 2 equals True"
If not, "Neither Test 1 or Test 2 equal True"
This is the formula:
=if(and(A1="Y",B1="Y",C1="Y",D1="Y"),"Test 1 equals True",if(and(A1="Y",B1="Y",C1="Y",D1="N"),"Test 2 equals True","Neither Test 1 nor Test 2 equal True"))

Excel: Match 2 Items, Including if Date is Between a Date Span on Multiple Worksheets

I have 2 worksheets:
Worksheet 1: Member ID, Engagement Date and other data.
Worksheet 2: Member ID, Policy Begin Date, Policy End Date and other data.
On Worksheet 1, I want to return a policy type name (from Worksheet 2), if Worksheet 1's Member ID matches Worksheet 2's Member ID AND if Worksheet 1 Engagement Date falls between Worksheet 2's Policy Begin and End Date...
The following is the formula I tried and also have attempted extensive research, to no avail:
=INDEX('Program Data'!M2:M25671,MATCH(A2:A489&F2>='Program Data'K2&F2<='Program Data'L2,'Program Data'!E2:E25671,0))
Replace your MATCH with an AGGREGATE that Calculates the SMALLest row where the Policy ID and Dates all match up.
So, we want AGGREGATE(15, 6, <SOME CODE>, 1) to get the Smallest non-error value in a list created by <SOME CODE>
The first thing that <SOME CODE> will want is the ROW we are looking at (minus one, because I see that you are skipping the header row...) which is ROW(Sheet2!$A$2:$A$25671)-1
If the Row does not match, we want to either make it massive or make it error (even better, because then it gets completely skipped). How to do this? Well, I have the POWER function for that. If you try POWER(10,999) you get a #NUM! error, because 10^999 is too large a number for Excel. If you try POWER(0,999) you get 0, because 0^anything is 0. So, we'll just add some POWER to our ROWs to make it error-out when we don't want them.
But, now we need to decide between 10 and 0. Fortunately, Logical statements can be treated as Bitwise Multiplication (True = 1 and False = 0`)
So, --(Sheet2!$A$2:$A$25671=$A2) will give us 1 when the First Columns (Member ID) match, --(Sheet2!$B$2:$B$25671<=$B2) will make sure that the Policy Start Date is before-or-on the record date, and --(Sheet2!$C$2:$C$25671>=$B2) will check the End Date. Multiply it all together, and we get 1 when the row matches, and 0 when it doesn't.
Now, if we take that away from 1, we get the opposite: 0 when we want 0, and 1 when we want 10. So multiply that by 10, and shove it in the POWER function, and add that to the ROW to get <SOME CODE>. Dump it all in the AGGREGATE from the start, and voila
=AGGREGATE(15,6,ROW(Sheet2!$A$2:$A$25671)-1+(POWER(10*(1-(Sheet2!$A$2:$A$25671=$A2)*--(Sheet2!$B$2:$B$25671<=$B2)*--(Sheet2!$C$2:$C$25671>=$B2)),999)),1)
Then, just use that in place of your MATCH (it will generate a #NUM! error when no policy is found)
=INDEX(Sheet2!M2:M25671,AGGREGATE(15,6,ROW(Sheet2!$A$2:$A$25671)-1+(POWER(10*(1-(Sheet2!$A$2:$A$25671=$A2)*--(Sheet2!$B$2:$B$25671<=$B2)*--(Sheet2!$C$2:$C$25671>=$B2)),999)),1),1)

Excel Using AND and OR together on the IF function

I have a problem that I cant figure out how to solve. currently I am solving this in excel but eventually be using sql.
We have a survey which is meant to run when the billed amount reaches ;
•first trigger $50k, then $150, then $250.
Sample Data
'last run' is when the survey last ran and 'Current Value' is the current billed amount.
So for row 1 , the survey last ran when billed amount was 55000 and now it is 160000 which is greater than the threshold 150K so survey should run hence it should return 'true'.
Row 2 : is also true because current value is greater than 'last run and also 'is >= 150K
Row 3: is also true because it has passed the threshold of 150K
Row 4 : should return false because between last ran and current value there isn't any threshold passed.
If
CurrentValue >= Last Run
And Current Value >= 50K or 150K or 250K
then 'True' Else false
We are going to drive the survey Initiation from the true or false returned from this.
The data is only sample data , values for current and last run can change but the trigger amounts will remain the same.
any help would be appreciated.
I understand your question this way:
You want to calculate which trigger the last Run value was checked against, and which trigger the Current Value is checked against, and if they are different and the Current Value is greater than last Run then we need to run the survey again (return TRUE), otherwise we don't (return FALSE).
If the above understanding is incorrect, please let me know.
To calculate this I would simply build one IF-statement expression that determines which trigger that last Run used, and the same for Current Value, and compare them.
Here are the two formulas:
=IF(A2>=250000;3;IF(A2>=150000;2;IF(A2>=50000;1;0)))
=IF(B2>=250000;3;IF(B2>=150000;2;IF(B2>=50000;1;0)))
Then we need to put it all together, so here's the final formula:
=AND(
IF(A2>=250000;3;IF(A2>=150000;2;IF(A2>=50000;1;0)))
<>IF(B2>=250000;3;IF(B2>=150000;2;IF(B2>=50000;1;0)))
;B2>A2)
(remove linebreaks and put it all together on one long line)

Excel dynamic data series. Unusual data look and chart

Since I solved previous problem with collecting data from database, I need to put that data on a chart now. I am working on a report generating software called ReportWorx.
Problem is, data comes in series and looks like this:
ID DATE SAMPLE
1 XX-XX-XX VALUE
1 XX-XX-XX VALUE
1 XX-XX-XX VALUE
2 XX-XX-XX VALUE
2 XX-XX-XX VALUE
3 XX-XX-XX VALUE
3 XX-XX-XX VALUE
I can not change how it looks because it is generated automatically. What I want is linear chart in which 1, 2, 3 are series name and of course next to it DATE and VALUE are put on a linear chart (or bargraph, w/e) (Date at X axis, Value at Y axis).
I can`t specify how many records will be there (how many rows) but I found few solutions about creating dynamically increasing charts, so probably it will not be a poblem. I just do not know how to separate thos ID series from each other.
EDIT:
I have found a solution in VBA according to the first answer. Here you have VBA code below:
Sub Rewrite()
Dim row, id
For row = 38 To 1000
For id = 1 To 37
If Sheet1.Cells(row, 1).Value = id Then
Sheet2.Cells(row, 1).Value = Sheet1.Cells(row, 2)
Sheet2.Cells(row, id + 1).Value = Sheet1.Cells(row, 3)
End If
Next id
Next row
End Sub
Thank You #sancho.s
I will post a solution that I use a lot for cases like yours.
With reference to the figure (where I used sample numbers), you set up 3 new columns (D:F here), the header of which contain the corresponding labels. Then you use a formula for "splitting" the list of X data (column B here) associated with each label, and assigning a "NULL" value for data not corresponding (#N/A here, but you can choose whatever you want):
=IF($A3=D$2,$B3,$B$1)
You enter this in D3. The absolute/relative indexing used allows for copy-and-paste throughout D3:F9.
Cell B1 here contains the "NULL" value.
Then you plot 3 series: column C against columns D, E, F.
PS: I guess you could split the Y data column instead, with similar results. For some reason that I do not recall, I decided a long time ago that this was the best option, at least in my case then. You may want to try out the other option.
PS2: This also works for data that is not sorted by label.
PS3: Using NA() as the "NULL" value avoids cell values being taken as zero and then showing up in the chart, as it is the case with other errors (e.g., try using =1/0 in B1). It is the best option I found so far. Alternatively (just in case you find it useful), you can use an explicit value which is outside the actual X data range, but then you would have to manually set the X axis range. All this is for a Scatter plot, just check what works for your case.

Resources