Display all SSRS report field values without line breaks - reporting-services

I have an SSRS report with a dataset that I cannot modify. I can only change the report's format.
I am trying to figure out how to have one of the reports fields display its many values inline in a list or csv fashion. Right now it prints a value and does a line break, then the next value and another line break, and so on... I would like my values to print without the line breaks.
I've tried using the Replace function in an expression (replace vbcrlf with ", ") with no success...

You're not quite providing enough information to reliably answer the question. Most likely, your question is a duplicate of this question, and my answer there will answer your question as well. The basics are:
Create a multi-value parameter #MyParameter
Set the default values for the parameter to be retrieved from your dataset
In your textbox use the expression =Join(Parameters!MyParameter.Value, ", ")
Same disclaimer holds here as well: if there are a lot of values this solution may not work very well.

It sounds like you just want an expression to remove the line feed characters in your source data so that it prints on one line. You'll probably need a bit of trial and error to work our what the characters actually are but you probably want to start with replacing:
vbCrLf
vbLf
vbCr
More on replacing line breaks in this question
You could create a Code function in the report to do the replacing, similar to the answer in this question.

Related

Expression in Textbox not passing value to the table

Obviously I am not an Access expert or I would not be asking this question. I created a small database with several tables. On a form, there are several combo boxes for the user to choose different combinations of medium, paper, sizes, etc. I have already created an expression that returns the correct value I need, but I cannot figure out how to get this value into the correct field on the table to store with the record the form is creating. Below are screen shots of the form and a couple of the tables. I have also included the expression I am using. I need the value that the expression returns to go into tbl1Artwork and populate the ArtWorkSKU field.
Expression:
=Left([PieceName],4) & [cbxArtist].Column & [cbxMedium].Column & [cbxPaperType].Column & [cbxPrintType].Column & [cbxSize].Column
The ArtWorkSKU text box is unbound as I had to type the expression in there. I am not sure if this is the correct way to accomplish the goal. In the tables below, except for the PK, all fields are Short Text.
All guidance is greatly appreciated.
Saving calculated data is usually not necessary and can be risky. Saved value can become 'out of sync' with raw data. Value can be calculated when needed.
Saving calculated data requires code (macro or VBA).
Can be as simple as Me!fieldname = Me.controlname.
Real trick is figuring out what event(s) to put code into. In your case, most likely form BeforeUpdate.
Advise not to use spaces nor punctuation/special characters (underscore only exception) in naming convention. Better would be ArtworkSKU or ArtworkSKUnum or Artwork_SKU_Num.
Create the following function in VBA:
Function UpdateSKU()
Me.ArtWorkSKU = Left(Me.[PieceName],4) & Me.[cbxArtist].Column(3) & _
Me.[cbxMedium].Column(2) & Me.[cbxPaperType].Column(2) & _
Me.[cbxPrintType].Column(2) & Me.[cbxSize].Column(2)
End Function
Then, on the form, update the After Update event property (not vba) of each "feeder" control to:
After Update: =UpdateSKU()

Remove Blank Lines from String SSRS

I have a field in my SSRS report that has multiple carriage returns, for example:
First, get materials
Next, glue them all together
Last, let dry for two hours
All six lines are in in the one field, its not 7 rows. I know I can replace/remove the carriage returns, but what I am really looking for is to be able to just remove the blank lines. I would still want to keep the carriage returns on the lines that have text, like this:
First, get materials
Next, glue them all together
Last, let dry for two hours
I greatly appreciate any help on this.
Thanks!
I think your problem is that multiple return carriage/new line characters could be present in each line, while your expected result is divide each line by only one return carriage or new line character.
I think it can be avoided using Regex replace method (Yes, you can use Regex in SSRS).
If you are sure your source is generating the new line using carriage return you can use:
=System.Text.RegularExpressions.Regex.Replace(Fields!MultilineText.Value,
"\r\r+",Environment.NewLine)
Otherwise if your source is generating the next line via new line character (code 10 in ascii) you should use:
=System.Text.RegularExpressions.Regex.Replace(Fields!MultilineText.Value,
"\n\n+",Environment.NewLine)
Note most Windows systems use \r\n to determine an end of line, replace accordingly to your environment.
UPDATE:
=System.Text.RegularExpressions.Regex.Replace(Fields!MultilineText.Value,
"\r\n[\r\n]+",Environment.NewLine)
Let me know if this helps.
I got a good answer that I just figured out. My Address2 (second line of an address) is not always there in all the rows. So I was able to use a conditional to put a vbCrlf in or put Nothing in if there was no value in Address2.
So now, each concatenated line stacks up nicely without empty rows if there is no Address2. Probably could do this with Environment.Newline instead of the vbCurliff.
=Trim(Fields!IPA_Addr1.Value) & IIF(LEN(Trim(Fields!IPA_Addr2.Value)) > 0, vbCrLf, Nothing) & Trim(Fields!IPA_Addr2.Value) & IIF(LEN(Trim(Fields!IPA_Addr2.Value)) = 0, vbCrlf , Nothing) & Trim(Fields!IPA_City.Value) & ", " & Trim(Fields!IPA_State.Value) & " " & Trim(Fields!IPA_Zip.Value)

Inside bracket values goes to negative when getting a csv output - ssrs 2008

I have a matrix in ssrs 2008 and have an expression in one of its columns like:
= Fields!Name.Value & "(" & Fields!Score.Value & ")"
This is working fine and bringing the values inside the brackets like Jack(7.04) or John(6.39). Name is a nullable value, so if it is null then the value for this cell is simply like (7.23) or (6.11). My problem is that when I run the report and take the output as a csv files, the data who has NULL as their names are all converted to negative values without brackets in the output file like -7.23 or -6.11. I would like to see them like on the report output, (7.23) etc, on the csv file as well.
Current csv output
Jack(7.04)
John(6.39)
-7.23
-6.11
What I want
Jack(7.04)
John(6.39)
(7.23)
(6.11)
Note that it is working fine for pdf or excel outputs, it is only happening for csv outputs. How can I fix it? Any help would be appreciated.
Edit: It seems like it is happening because of '(' character. It is working when I use another, like '['. But I am supposed to use normal brackets '(' and ')'.
it's just a comment i don't have enough reputations to make comment.
Here are couple of thoughts.
1. Did you try with the text box properties
(Text box properties -> Number -> Negative numbers)
2. Try with if statement or switch statement=iif(Fields!score.Value>0,Fields!Name.Value & "(" & Fields!Score.Value & ")","(" & Fields!Score.Value & ")")

How to align each string in text in field column of ssrs

I have a field like this in the column field in ssrs.
QUINIDINEssssssssssssssssssssssssssssssssssssssssssssssssssssss GL INJ 80MG/ML
FLECAINIDEssssssssssssssssssssssssssssssssss TAB 50MG
TAMBOCORsssssssssssssssssssssssssssssssssssssssssssss TAB 50MG
and how can i align align like this...
QUINIDINEssssssssssssssssssssssssssssssssssssssssssssssssssssss GL INJ 80MG/ML
FLECAINIDEssssssssssssssssssssssssssssssssss(emptyspaceeeeeeeee)TAB 50MG
TAMBOCORsssssssssssssssssssssssssssssssssssssssssssss(emptyspa)TAB 50MG
each part of string align properly...
Any help...
Well, there are two ways to do this that I worked out, and neither is particularly elegant so I'd be surprised if someone doesn't have a better solution.
"t.a" in the code below is your table and column.
The SQL way:
SUBSTRING(t.a,1,CHARINDEX(' ',t.a,1))+REPLICATE('_',20)+REVERSE(SUBSTRING(REVERSE(t.a),1,CHARINDEX(' ',REVERSE(t.a),1)))
Change the value being replicated above from '' to ' ' and you are in business. I left it as '' to illustrate what it's doing.
The SSRS way, which is better from a DB standpoint:
=Mid(Fields!a.Value,1,InStr(Fields!a.Value," "))+StrDup(20,"_")+StrReverse(Mid(StrReverse(Fields!a.Value),1,InStr(StrReverse(Fields!a.Value)," ")))
This is precisely the same formula, executed by SSRS instead of by SQL Server.
I once used Switch to append spaces to a column field, like in the following example:
=Switch(LEN(Fields!FamilyMemberName.Value) = 1, " ",
LEN(Fields!FamilyMemberName.Value) = 2, " ",
LEN(Fields!FamilyMemberName.Value) = 3, " ")
But I didn't have to bother about the expression getting longer, since I know exactly how many spaces I should append and it wasn't more than 15.
You could use Switch in your case too or you could write a VB function in the Code tab of Report Properties window and pass the values, use some loops to generate the spaces you require.
Or it's much easier in MS SQL, all you got to do is append SPACE(NoOfSpacesInInteger) to the field.

Symbol required to enter date in text strings

I am working on a homework assignment for school, and I have come across one particular question which has me a little stumped. The question is, 11. What symbol does Access SQL require to enter dates in text strings? I have found the use of ''(single quotes), " " (double quotes), and #(pound sign), but I have not been able to find a definitive answer to this particular questions. Which would be the correct answer?
Since this is homework, I'll show you how to find the answer you need.
Open the Immediate window (Ctrl+g) and run both of these statements (pressing Enter after each):
Debug.Print TypeName("5/2/2013")
Debug.Print TypeName(#5/2/2013#)
However it's safer to use yyyy/m/d format with literal date values to avoid locale issues ... ie does 5/2/2013 represent May 2nd or Feb 5th?
Debug.Print TypeName("2013/5/2")
Debug.Print TypeName(#2013/5/2#)