Crystal Reports select expert OR statement on CSV - crystal-reports

I am using the Select Expert to filter on a combination of 3 fields:
({flatfile_csv.site} = "L" and {flatfile_csv.bursguar} = "1")
or
({flatfile_csv.site} = "L" and {flatfile_csv.bursnorm} = "1")
In this case it only matches:
({flatfile_csv.site} = "L" and {flatfile_csv.bursguar} = "1")
If I swap the statements around:
({flatfile_csv.site} = "L" and {flatfile_csv.bursnorm} = "1")
or
({flatfile_csv.site} = "L" and {flatfile_csv.bursguar} = "1")
Then it only handles
({flatfile_csv.site} = "L" and {flatfile_csv.bursnorm} = "1")
It seems to completely ignore the second part of the OR statement. Any idea how to implement an OR in CR?

I've never used CR with a CSV file before, so I don't know how it's handling those empty strings. Try setting the selection formula to "Default Values for Nulls" instead of "Exception for Nulls" with this:
{flatfile_csv.site} = "L"
and
(
{flatfile_csv.burnsnorm}="1"
or {flatfile_csv.burnsguar}="1"
)

Related

How to add fields in table to a Word document with Powershell

I'm able to add fields in the footer of a word document, like this :
$footer = $Section.Footers.Item(1)
$footer.Range.Text = "";
$Footer.Range.ParagraphFormat.Alignment=2
$Range = $Footer.Range
$null = $ExistingDoc.Fields.Add($footer.range, 33) # Page
$Range.SetRange($Range.end + 1,$Range.end + 1)
$null = $Range.InsertBefore(' of ')
$Range.SetRange($Range.end + 1,$Range.end + 1)
$null = $ExistingDoc.Fields.Add($range, 26) # Total Page
$Range.SetRange($Range.star,$Range.start)
$null = $Range.InsertBefore('Page ')
$Footer.Range.ParagraphFormat.Alignment=2
But I'm not able to add a table and put fields in it.
I tried many syntaxes with no luck like :
$table2 = $ExistingDoc.Tables.Add($footer.range,2,3)
$range2 = $table2.cell(1,1).select
$null = $ExistingDoc.Fields.Add($Footer.range.Tables(2), 33)
or
$table2 = $ExistingDoc.Tables.Add($footer.range,2,3)
$null = $ExistingDoc.Fields.Add($table2.cell(1,1), 33)
I did it with a macro and find the following code :
Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty, Text:= _
"PAGE ", PreserveFormatting:=True
But no luck to convert it to Powershell, any help is welcome.

Split Array if comma is found

$FruitArray[0] = "Banana, Orange, Peach, Mangoes"
$FruitArray[1] = "Apple, Banana"
$FruitArray[2] = "Peach"
$FruitArray[3] = "Mangoes"
How to split the array items to get the following results?
$FruitArray[0] = "Banana"
$FruitArray[1] = "Orange"
$FruitArray[2] = "Peach"
$FruitArray[3] = "Mangoes"
$FruitArray[4] = "Apple"
$FruitArray[5] = "Banana"
$FruitArray[6] = "Peach"
$FruitArray[7] = "Mangoes"
Split the array elements at commas and assign the result back to the variable.
$FruitArray = $FruitArray -split ',\s*'

Email attachments recorded in Excel

The macro below is designed to take x amount of emails, count how many attachments there are in each mail and then locate certain file formats. It will then record what it has found in a certain excel spreadsheet.
The macro works perfectly, but I am now wanting to add in another scenario. The scenario I want to add in is that of if an email has more than 1 .csv file, it shall be recorded as "Multiple" rather than "YES".
Has anyone got any ideas to implement this scenario?
If .Attachments.Count = 0 Then
csv_report = "NO"
pdf_report = "NO"
xls_report = "NO"
End If
If .Attachments.Count > 0 Then
For i2 = 1 To .Attachments.Count
If LCase(Right(.Attachments(i2).Filename, 4)) = ".csv" Then
csv_report = "YES"
GoTo CSVyes 'if a .csv file is found, it skips to the PDF attachment checker
Else
csv_report = "NO"
End If
Next
CSVyes:
For i2 = 1 To .Attachments.Count
If LCase(Right(.Attachments(i2).Filename, 4)) = ".pdf" Then
pdf_report = "YES"
GoTo PDFyes 'if a .pdf file is found, it skips to the XLS attachment checker
Else
pdf_report = "NO"
End If
Next
PDFyes:
For i2 = 1 To .Attachments.Count
If LCase(Right(.Attachments(i2).Filename, 4)) = ".xls" Or LCase(Right(.Attachments(i2).Filename, 5)) = ".xlsx" Or UCase(Right(.Attachments(i2).Filename, 4)) = ".XLS" Then
xls_report = "YES"
GoTo XLSyes 'if a .xls file is found, it skips to the end of the checks
Else
xls_report = "NO"
End If
Next
XLSyes:
End If
Sheets("Mail Report").Activate
Range("C65000").End(xlUp).Offset(1).Value = csv_report
Range("D65000").End(xlUp).Offset(1).Value = pdf_report
Range("E65000").End(xlUp).Offset(1).Value = xls_report
subject_line = mail.Subject
Range("A65000").End(xlUp).Offset(1).Value = subject_line
Check this below code. I have just added If Else block to check if Attachment.count > 1. THat's It.
If .Attachments.Count > 0 Then
For i2 = 1 To .Attachments.Count
If LCase(Right(.Attachments(i2).Filename, 4)) = ".csv" Then
If .Attachments.Count > 1
csv_report = "MULTIPLE"
Else
csv_report = "YES"
End If
GoTo CSVyes 'if a .csv file is found, it skips to the PDF attachment checker
Else
csv_report = "NO"
End If
Next
After many attempts to implement this scenario, I was unsuccessful. So I figured to put an alternative method after this macro.
This macro is just a minor part of a much larger scale macro, but basically when there was blanks left in Column B I would replace a "YES" with "Multiple", which was sufficient to the outcome.
Dim kk As Long
Sheets("Mail Report").Activate
LastRow = Cells(Rows.Count, 1).End(xlUp).Row
For kk = 1 To LastRow
If IsEmpty(Cells(kk, 2)) Then
Cells(kk, 2) = MAIN_PATH & "For Resolution\" & "multiple_csv\"
Cells(kk, 3) = "MULTIPLE"
End If
Next kk

Crystal Reports XI Record Selection Issue using Multiple Criteria

A huge thanks to anyone that tries to help me in advance!
I'm not a programmer, but I have to work with Crystal Reports XI at work.
I have been asked to put together a report that will allow us to see all of the cases numbers that have the following criteria: It must have a 0 in the AE field for the previous three months.
So Jan 2015 AE=0, Dec 2014 AE=0 and Nov 2014 AE=0. In other words if a case has 0 AE for those three months it will show up. If not it won't.
I've worked on this for several days and stumped (like I said I'm not a programmer and have learned a high appreciation for the talents and skills programmers bring to the table!
What I have so far is only one of numerous attempts to get the results I'm looking for, but here is the formula I currently have in the Record Select
(which of course does not work):
{CASE.CASE_OWNER} = "TIM" and
not ({UNIT.RESP_CODE} in "20" to "74") and
{CASE.ARCHIVE} = "F" and
{MICRO_DATA.AE} = 0.00 and {MICRO_DATA.REF_YY} = "2015" and {MICRO_DATA.REF_MM} = "01" and
{MICRO_DATA.AE} = 0.00 and {MICRO_DATA.REF_YY} = "2014" and {MICRO_DATA.REF_MM} = "12" and
{MICRO_DATA.AE} = 0.00 and {MICRO_DATA.REF_YY} = "2014" and {MICRO_DATA.REF_MM} = "11"
your and conditions are creating problems.
{CASE.CASE_OWNER} = "TIM" and
not ({UNIT.RESP_CODE} in "20" to "74") and
{CASE.ARCHIVE} = "F" and
{MICRO_DATA.AE} = 0.00 and
({MICRO_DATA.REF_YY} = "2015" and {MICRO_DATA.REF_MM} = "01") OR
({MICRO_DATA.REF_YY} = "2014" and {MICRO_DATA.REF_MM} = "12") OR
({MICRO_DATA.REF_YY} = "2014" and {MICRO_DATA.REF_MM} = "11")
This is one way and one more way is to don't write in record selection formula just write in you condition in formulas and pick data.
Edit..........................
and not(databasefield in "")
Edit---------------------
if ({MICRO_DATA.REF_YY} = "2015" and {MICRO_DATA.REF_MM} = "01" and isNull(yourdatabasefield))
then true
else false
write this in supress part of the date field where you are displaying

Need to convert a simple number set to text with if, then, else in Crystal

Fairly new to Crystal Reports. Need to convert numbers to text in a formula. This is what I've tried, along with several others, but returns an error. Any suggestions helpful!
IF {Ref_Referrals.ReferralStatusID} = 1 then totext "Open"
or if 2 = then totext = "Closed-Sale"
or if 3 = then totext = "Closed-Expired"
or if 4 = then totext = "Closed-No Interest"
or if 5 = then totext = "Closed-Extended"
or if 6 = then totext = "Closed-Sale(Auto)"
or if 7 = then totext = "Closed-Future Interest"
or if 8 = then totext = "Closed Not Qualified"
else totext is null
You'll want to use a CASE-statement for this.
select {Ref_Referrals.ReferralStatusID}
case 1 : "Open"
case 2 : "Closed-Sale"
case 3 : "Closed-Expired"
case 4 : "Closed-No Interest"
.
.
.
default : ""
If you're doing this inside the actual Crystal Report, you need to use the Switch statement.
Switch ({Ref_Referrals.ReferralStatusID} = 1, "Open",
{Ref_Referrals.ReferralStatusID} = 2, "Closed-Sale",
{Ref_Referrals.ReferralStatusID} = 3, "Closed-Expired",
{Ref_Referrals.ReferralStatusID} = 4, "Closed-No Interest",
{Ref_Referrals.ReferralStatusID} = 5, "Closed-Extended",
{Ref_Referrals.ReferralStatusID} = 6, "Closed-Sale(Auto)",
{Ref_Referrals.ReferralStatusID} = 7, "Closed-Future Interest",
{Ref_Referrals.ReferralStatusID} = 8, "Closed Not Qualified",
True, "")
The last line of the Switch returns a 0-length string if none of the previous 8 conditions are true.
Edit: If for some reason you still really want to do this with IF THEN ELSE, you would need to use nested ELSE IFs. The SWITCH is designed to replace nested ELSE IF, though. Just a thought.