Ssrs expression returns #error when I open my report and see the total - ssrs-2008

=if(Fields!Type6.Value="S","",Sum(Fields!Col6.Value))
this is above is a expression which i used for a Sum of column which don't Contains "S"
What I have tried:
this Expression return #Error
Hide Copy Code
if(Fields!Type6.Value="S","",Sum(Fields!Col6.Value))
This Works Fine But it will sum up also alphanumeric column numeric characters
Hide Copy Code
if(Fields!Type6.Value="S","",Val(Sum(Fields!Col6.Value)))
i have used dynamic column so i don't know which is numeric column or string
so plz help me to out from this

By entering "" and a sum you are causing SSRS to try and add a string and a number. Change it to
=if(Fields!Type6.Value="S",cint(0),Sum(Fields!Col6.Value))
or
=if(Fields!Type6.Value="S",cdec(0),Sum(Fields!Col6.Value))

Related

How do I combine static text and fields into a single field

I need to do this for multiple fields and text
So in one field I would want it be TEXT FIELD TEXT FIELD TEXT FIELD
So it would be L 12 X W 12 X 12
The letters would be static text and the numbers would be an actual field
Thanks
You would use a Formula Field to do this. Within the Formula Field you can concatenate plain text with database fields. Here is an example of a formula for a Formula Field.
"This is my custom string." & {table.column} & " more custom text.";
This formula will concatenate the first string contained within the double quotes, the value of {table.column}, and the second string contained within double quotes. If we assume the value of {table.column} is "Delta365", then the output of the formula field would be the following:
This is my custom text. Delta365 more custom text.
EDIT: Response to follow-up question.
To remove the decimal from a numeric value while using a formula to concatenate the numeric value to a string of text you should use one of the overloaded ToText() function. ToText(x,y) is the most commonly used versions of this function. Here is a breakdown of the arguments for this function.
x is a Number or Currency value to be converted into a text string.
y is a Format String that determines how the value of x will be
displayed.
There are two ways to use this function to remove the decimal point. Here is an example of each method using the same example I used previously.
"This is my custom string." & ToText({table.column},0) & " more custom text.";
Or
"This is my custom string." & ToText({table.column},"#") & " more custom text.";
The difference between these two formulas is the value of the y argument. When y = 0, the value of {table.column} will be rounded to the nearest whole number. When y = "#", the value of {table.column} is not rounded and instead will truncate and not show any digits beyond the decimal point.

Azure Data Factory - Dynamic Skip Lines Expression

I am attempting to import a CSV into ADF however the file header is not the first line of the file. It is dynamic therefore I need to match it based on the first column (e.g "TestID,") which is a string.
Example Data (Header is on Line 4)
Date:,01/05/2022
Time:,00:30:25
Test Temperature:,25C
TestID,StartTime,EndTime,Result
TID12345-01,00:45:30,00:47:12,Pass
TID12345-02,00:46:50,00:49:12,Fail
TID12345-03,00:48:20,00:52:17,Pass
TID12345-04,00:49:12,00:49:45,Pass
TID12345-05,00:50:22,00:51:55,Fail
I found this article which addresses this issue however I am struggling to rewrite the expression from using an integer to using a string.
https://kromerbigdata.com/2019/09/28/adf-dynamic-skip-lines-find-data-with-variable-headers
First Expression
iif(!isNull(toInteger(left(toString(byPosition(1)),1))),toInteger(rownum),toInteger(0))
As the article states, this expression looks at the first character of each row and if it is an integer it will return the row number (rownum)
How do I perform this action for a string (e.g "TestID,")
Many Thanks
Jonny
I think you want to consider first line that starts with string as your header and preceding lines that starts with numbers should not be considered as header. You can use isNan function to check if the first character is Not a number(i.e. string) as seen in the below modified expression:
iif(isNan(left(toString(byPosition(1)),1))
,toInteger(rownum)
,toInteger(0)
)
Following is a breakdown of the above expression:
left(toString(byPosition(1)),1): gets first character fron left side of the first column.
isNan: checks if the character is "not a number".
iif: not a number, true then return rownum, false then return 0.
Or you can also use functions like isInteger() to check if the first character is an integer or not and perform actions accordingly.
Later on as explained in the cited article you need to find minimum rownum to skip.
Hope it helps.

How to delete space in character text?

I wrote a code that automatically pulls time-related information from the system. As indicated in the table is fixed t247 Month names to 10 characters in length. But it is a bad image when showing on the report screen.
I print this way:
WRITE : 'Bugün', t_month_names-ltx, ' ayının'.
CONCATENATE gv_words-word '''nci günü' INTO date.
CONCATENATE date ',' INTO date.
CONCATENATE date gv_year INTO date SEPARATED BY space.
TRANSLATE date TO LOWER CASE.
I tried the CONDENSE t_month_names-ltx NO-GAPS. method to delete the spaces, but it was not enough.
After WRITE, I was able to write statically by setting the blank value:
WRITE : 'Bugün', t_month_names-ltx.
WRITE : 14 'ayının'.
CONCATENATE gv_words-word '''nci günü' INTO date.
CONCATENATE date ',' INTO date.
CONCATENATE date gv_year INTO date SEPARATED BY space.
TRANSLATE date TO LOWER CASE.
But this is not a correct use. How do I achieve this dynamically?
You could use a temporary field of type STRING:
DATA l_month TYPE STRING.
l_month = t_month_names-ltx.
WRITE : 'Bugün', l_month.
WRITE : 14 'ayının'.
CONCATENATE gv_words-word '''nci günü' INTO date.
CONCATENATE date ',' INTO date.
CONCATENATE date gv_year INTO date SEPARATED BY space.
TRANSLATE date TO LOWER CASE.
You can not delete trailing spaces from a TYPE C field, because it's of constant length. The unused length is always filled with spaces.
But after you assembled you string, you can use CONDENSE without NO-GAPS to remove any chains of more than one space within the string.
Add CONDENSE date. below the code you wrote and you should get the results you want.
Another option is to abandon CONCATENATE and use string templates (string literals within | symbols) for string assembly instead, which do not have the annoying habit of including trailing spaces of TYPE C fields:
DATA long_char TYPE C LENGTH 128.
long_char = 'long character field'.
WRITE |this is a { long_char } inserted without spaces|.
Output:
this is a long character field inserted without spaces

Crystal Report : formula for Splitting string on / and concatenating it with other string

I have string coming in this format WORVS/000017/0005.
I want to split the string on /. I want only 000017 from this string and further I had another column to which it has to be concatenated.
I need a formula for same.
Create a formula and add below code.
Split (dbfield,"/")[2]
Have an eye to this solution, Its Simple, Splitting "Full Name" into First and Last , keeping, Excluding Last name and returning First Name part.
Splitting String

Postgresql, treat text as numbers for getting MAX function result

Still didnt fix issue with dates written as strings here comes another problem.
I have text column where only numbers as writen (like text).
By using function MAX I get incorrect result because there 9 is bigger than 30.
Is here any inline function like VAL or CINT or something that I can compare and use textual data (only numbers) like numbers in queries like SELECT, MAX and other similar?
How than can look like in following examples:
mCmd = New OdbcCommand("SELECT MAX(myTextColumn) FROM " & myTable, mCon)
You need to use max(to_number(myTextColumn, '999999'))
More details are in the manual: http://www.postgresql.org/docs/current/static/functions-formatting.html
If all "numbers" are integers, you can also use the cast operator: max(myTextColumn::int)
If your text values are properly formatted you can simply cast them to double, e.g.: '3.14'::numeric.
If the text is not formatted according to the language settings you need to use to_number() with a format mask containing the decimal separator: to_number('3.14', '9.99')
To get the MAX works poterly you need to first convert your text field in numeric format
mCmd = New OdbcCommand("SELECT MAX(TO_NUMBER(myTextColumn, '99999')) FROM " & myTable, mCon)