#Error when exporting to .csv from ssrs when trying to replace a comma with another field - string

I am trying to replace a comma with another field so you can import the data using a csv. I can do that successfuly by adding .ToString().Replace(","," And ") to the end of the field
EX. Fields!Fieldname.Value.ToString().Replace(","," And ")). This will replace the comma with the word And.
The issue I have encounterd is when the field is blank. It then exports a #Error in the cell. I have tried hiding the cell if it is blank but that works for everything but when it exports to a .csv.
If I cannot get the field to be just blank I would like to have it display 99.
Please help.
I have tried this as well...
=Iif(isNothing(Fields!FieldName.Value),"99",(Fields!FieldName.Value.ToString().Replace(","," And ")))
It still displayed an error

The problem is that you are trying to convert NULL (Nothing) to a string. Both sides of IIF are evaluated so even though you will never see the result, false part is failing when FieldName is null.
TO get round this, we first check if the field is null, then replace that with and emptry string "" and then do the ToString() bit.
try the following...
=IIF(
isNothing(Fields!TestField.Value),
"",
(IIF(IsNothing(Fields!TestField.Value),
"",
Fields!TestField.Value
).ToString().Replace(","," And "))
)

Related

How to set up prefixes on saved search for multiple choices in netsuite?

I have a multiple select field that allows multiple selections of colors. I created a formula that would append a prefix of "color-" to each selected list, but it only appends it to the the beginning of the field. I'm not sure how I can split the field results up for the formula to where I can get it showing up for all results.
CASE WHEN {custitemtag_color1} is NULL
THEN ''
ELSE 'color-'||{custitemtag_color1}
END
Results with multiple selections show: color-Black,Lime Green,White
Expected Results need to show: color-Black,color-Lime Green,color-White
What's happening is that NetSuite returns "Black,Lime Green,White" as a single result for the multi-selection, then you're prepending "color-" to that text returned. To work around it within your saved search, you could simply replace any instances of the comma (",") with ",color-":
CASE WHEN {custitemtag_color1} is NULL THEN '' ELSE 'color-'|| REPLACE({custitemtag_color1}, ',', ',color-') END

invalid input syntax for type numeric: " "

I'm getting this message in Redshift: invalid input syntax for type numeric: " " , even after trying to implement the advice found in SO.
I am trying to convert text to number.
In my inner join, I try to make sure that the text being processed is first converted to null when there is an empty string, like so:
nullif(trim(atl.original_pricev::text),'') as original_price
... I noticed from a related post on coalesce that you have to convert the value to text before you can try and nullif it.
Then in the outer join, I test to see that there's a limited set of acceptable characters and if this test is met I try to do the to_number conversion:
,case
when regexp_instr(trim(atl.original_price),'[^0-9.$,]')=0
then to_number(atl.original_price,'FM999999999D00')
else null
end as original_price2
At this point I get the above error and unfortunately I can't see the details in datagrip to get the offending value.
So my questions are:
I notice that there is an empty space in my error message:
invalid input syntax for type numeric: " " . Does this error have the exact same meaning as
invalid input syntax for type numeric:'' which is what I see in similar posts??
Of course: what am I doing wrong?
Thanks!
It's hard to know for sure without some data and the complete code to try and reproduce the example, but as some have mentioned in the comments the most likely cause is the to_number() function you are using.
In the earlier code fragment you are converting original_price to text (string) and then substituting an empty string ('') if the value is NULL. Calling the to_number() function on an empty string will give you the error described.
Without the full SQL statement it's not clear why you're putting the nullif() function around the original_price in the "inner join" or how whether the CASE statement is really in an outer join clause or one of the columns returned by the query. However you could perhaps alter the nullif() to substitute a value that can be converted to a number e.g. '0.00' instead of ''.
Sorry I couldn't share real data. I spent the weekend testing small sets to try and trap the error. I found that the error was caused by the input string having no numbers, which is permitted by my regex filter:
when regexp_instr(trim(atl.original_price),'[^0-9.$,]') .
I wrongly expected that a non numeric string like "$" would evaluate to NULL and then the to_number function would = NULL . But from experimenting it seems that it needs at least one number somewhere in the string. Otherwise it reduces the string argument to an empty string prior to running the to_number formatting and chokes.
For example select to_number(trim('$1'::text),'FM999999999999D00') will evaluate to 1 but select to_number(trim('$A'::text),'FM999999999999D00') will throw the empty string error.
My fix was to add an additional regex to my initial filter:
and regexp_instr(atl.original_price2,'[0-9]')>0 .
This ensures that at least one number will be in the string and after that the empty string error went away.
Hope my learning experience helps someone else.

OR Formula in Word document not returning a value

I am working on a document where I need to be able to test multiple options in an if statement to see if one of them are true to decide if a paragraph displays on the document. I have been trying to figure out why my OR formula is not returning a value for me to test and I am not sure why it is not showing anything when it is updating.
I have inserted a field and added a formula within that field that I am hoping will work with my If statement to show the proper paragraph contens.
When I use an Or statement, even one as simple as { OR(1=1) } and update and toggle the field I get no result. From what I have read I should get a 1 or a 0, but I don't seem to get either of these results. The line just ends up blank. When I test it with my If formula it always shows the false result, even when the Or contains a true result.
The formula I am currently working with is:
{ IF{ OR("$event.eventType.name}" = "Birthday", "$event.eventType.name}" =
"Conference" } "Yes" "No" }
If I update and toggle the Or field it shows blank, no result either true or false, and makes the If formula show as false event on results where it should show true. As I mentioned above I even tried setting it to 1=1 and still could not get it to show as true. Not sure if there is something I am missing in working with the formula.
Any suggestions would be appreciated.
It's not clear from your post what $event.eventType.name is. Presumably it's a field generated by an Addin. In that case, you should be able to use something like:
{IF{={IF{$event.eventType.name}= "Birthday" 1 0}+{IF{$event.eventType.name}= "Conference" 1 0}# 0}> 0 "Yes" "No"}
or:
{={IF{$event.eventType.name}= "Birthday" 1 0}+{IF{$event.eventType.name}= "Conference" 1 0} \# "'Yes',,'No'"}
Note: The field brace pairs (i.e. '{ }') for the above example are all created in the document itself, via Ctrl-F9 (Cmd-F9 on a Mac); you can't simply type them or copy & paste them from this message. Nor is it practical to add them via any of the standard Word dialogues. The spaces represented in the field constructions are all required. If your fields are a kind of mergefield, you'll need to insert 'MERGEFIELD ' at the start of each one, thus:
{MERGEFIELD $event.eventType.name}

WorksheetFunction.value() missing in Excel

In a spreadsheet formula, =VALUE("$100") will evaluate to the numeric value of 100. I then tried to access this function in VBA via WorksheetFunction object, however it is missing.
In VBA I tried the conversion function Val("$100"), however that returns 0. So how can I accomplish this via VBA?
Val() only really works if the string is all numbers I'm afraid - currency signs cause it a problem.
If you're always going to have the same currency sign in the string, it might be worth using something like
StringName = replace(StringName, "$", "")
to take out the $ by replacing it with "" - otherwise if your strings aren't always going to be this predictable the below question might help:
How to find numbers from a string?
see https://learn.microsoft.com/en-us/office/vba/api/excel.worksheetfunction.numbervalue
example of using above, which will return a value of -1234.56:
MsgBox WorksheetFunction.NumberValue("-$1,234.56", ".", ",")
Note that if the result is non-numeric, it throws an error. For example (swapping the comma grouping and decimal character params which is invalid in this case):
MsgBox WorksheetFunction.NumberValue("-$1,234.56", ".", ",")
I don't understand why the above link doesn't have any version info. It is currently dated 2019‎-‎05‎-‎23 - no idea if that's because it is new or if it was recently updated.

Error using TransferSpreadsheet to import an Excel spreadsheet

I have a routine that helps me locate a the row of word in a standardized worksheet.
Based on the location of the word - for example, I search in column 'A'
It finds the word on row 7.
I now know that I can use the range A8:M14 as the data I want to import into my table, so I created a function 'GETBASELINE' that would just return that string - "A8:M14"
So now I have a table called tbl_TEMP_Import with these fields
BASELINE|OCT|NOV|DEC|JAN|FEB|MAR|APR|MAY|JUN|JUL|AUG|SEP
I call it like so:
DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel12, "tbl_TEMP_Import", strPath, False, GetBASELINE(strPath, strSheet)
I get Error 2391 Field 'F1' doesn't exist in destination tbl_TEMP_Import
If I change it to 'True' for 'has field names'
I get Error 3270 'Property Not Found'
I wish I could get better debugging. Doesn't seem too complex to accomplish this.
Answer with 'True' for 'has field names':
You have to give the table the field heading as well... so the code for GETBASELINE must equal "A7:M8" ... (I'm not sure where 14 came from)
A7:M7 are Field names
A8:M8 are 1st set of values
Answer with 'False' for 'has Field names':
You must change the field names, because the call brings in temp field names, F1,F2 and so on
Manually you can change the names. It is programmable as well.
In any event, once you call the script one way, be careful not to 'mix' them with each other! Delete one before you call the next

Resources