RDL report - change of header text in CSV export by parameter - reporting-services

I am working on rdl reports and as I had to add multilingual support, I need to be able to change the column headers' text by the selected language parameter.
I added this very basic custom expression to the header:
=IIF(Parameters!Language.Value="EN", "Date", "DateInDifferentLanguage")
but when I export the report to CSV this is completely ignored, moreover, the column header will be the assigned value's name.
I tried to search for solution for almost 2 days, but the only thing I found that I should use the DataElementName property. Well, for static values it works, but as the text is parameter-dependent I have to use custom expressions and this property does not allow me to use anything like that.
Hopefully, there will be no difference in the solution for grouped columns.
So, my question is: is it possible to add parameter-dependent custom expressions to grouped/not grouped columns?

EDIT: I just realized that you can't set the DataElementName property by expression. I'll leave this up in the off-chance that it may help in some way.
If you're wanting different expressions based on a parameter, try this:
Make sure you can see your Report Data. View -> Report Data(at the bottom)
Start by creating the parameter. Right click Parameters folder in the Report Data window -> Add Parameter... Let's call it 'Language'.
In the available values tab, click Specify Values. Add values for your languages, so the label will be what you want the viewer to see, make the value the same.
Label: English
Value: english
In the Expression you're trying to modify, simply put the available expressions you want in an SWITCH() block.
SWITCH(Parameters!Language.Value = 'english', [do english things],
Parameters!Language.Value = 'spanish', [do spanish things],
Parameters!Language.Value = 'chinese', [do chinese things],
True, [do english things])

Related

SSRS Font Color Using Wildcard parameter

Hi I have a report that i used a wild card search parameter so that i can pull record that contains a certain text.
For example: I need to search for subscription for Mary Johnson so on the keyword search box i just type "John". This set-up is working fine, but now I need to color that search keyword when found for each row. so i need assistance on expression code that mimics SQL syntax of LIKE in SSRS expression. I started to change the font color with =iif(Instr(Fields!ReportRecipients.Value)=Parameters!Keyword.Value,"Maroon","Black"), but it didnt work.
Please advise.
Sample
TOJo.eger#m.com; ruth.tuker#m.com;sandrae.espe#m.com; dan.gay#m.comIncludeReportTrueRenderFormatPDFSubjectDaily Report for IBC Medicare? was executed at #ExecutionTimeIncludeLinkFalsePriorityHIGH"
You can use some .net string functions directly in SSRS expressions. In your case you can use the Contains() function like this.
=IIF(
Fields!ReportRecipients.Value.Contains(Parameters!Keyword.Value),
"Maroon",
"Black"
)
If you are dealing with HTML and only want the search term to be highlighted then you can simply use this as the Value expression. You must leave the text box color properties as default.
=REPLACE(
Fields!ReportRecipients.Value,
Parameters!Keyword.Value,
"<span style=""color:red;"">" & Parameters!Keyword.Value & "</span>"
)
Finally, right-click the placeholder, choose properties and select Mark-up type as HTML
In this example, I used a country list and searched for the word "land", here's the results. The first column just uses the first method I described. The second column adds HTML tags.

SSRS - Multiple font or color within a chart item

I'm using Report Builder 3.0. Long story short, I want to make the font bold for the text in the red box that you see in the image below:
Basically, it's just one expression in the legend field of my value, however, for clarity's sake (for my end users) I wish to make the "title part" bold. I found the following solution for textboxes in a tablix using Html by checking off the "HTML – Interpret HTML tags as styles." checkbox within the Textbox's properties. (http://www.sqlchick.com/entries/2010/10/31/using-different-formats-within-a-single-textbox-in-ssrs.html)
However, I can't find anything similar for graphs! I mean if MS thought about it for tables, I presume they must've given it some thought for a chart setting too.
Thanks to all!
p.s. As an aesthetic solution to my problem, I did think of simply creating a new title field, moving it to the exact same location and formating it. But I'm surious whether there'd be some more "proper" way of doing this.
I'm using the same approach for one of my charts.
STEPS.
Select the Chart series to open property pane. In my case, the chart series name is TWR Chart Series
Select the color property and select to build the expression.
I'm posting one of my expression. You can build your own expression base don your field names etc.
=IIF(Fields!ProductID.Value = 1 OR Fields!ProductID.Value = 6,"#00425E",
IIF(Fields!ProductID.Value = 3 ,"#6B8797",
IIF(Fields!ProductID.Value = 5 OR Fields!ProductID.Value = 7,"#799179",
IIF(Fields!ProductID.Value = 4 AND Fields!sort.Value=99,"#6bb1be","#48597B"))))
If used sensibly, you should get your desired results.Good luck.

How to remove trailing zeros using ssrs?

I have a column DECIMAL(18,4). when I insert data like 123.45 it becomes 123.4500
I want to show it in SSRS like 123.45.
How to remove those zeros in SSRS?
Depending on what exporting formats your need you can set the number formatting to 0.####;(0.####)
I know this is compatible with the SSRS viewer and exporting to PDF, but Excel would take 123.0000 and show it as 123. instead of just 123
I dont agree with the accepted answer, casting to a string is another workaround:
=Str(NumericValueWithVariableDecimalPlaces)
Unfortunately a consequence is no numeric formatting settings will apply and setting cell Alignments to right causes numbers to be misaligned.
You can change the data type returned to SSRS to a FLOAT. That should do it :-)
Open SSRS Query Designer and add:
SELECT CONVERT(DOUBLE PERCISION,FIELD) FROM TABLE SOURCE
OR add to your select result from your Store Procedure source
SELECT CONVERT(DOUBLE PERCISION,FIELD) FROM TABLE SOURCE
This will remove trailing zeros: CDbl(Fields!YOURFIELD.Value)
This can be done in the SQL which you can do by casting the value to DECIMAL(18,2)
ex:
CAST(FieldName as DECIMAL(18,2))
but if you really want to do it in SSRS. You can right click on the textbox that the field is displaying in and go to textbox properties. In the pop-up box choose 'Number' and set the Category to 'Number' and then decimal places to 2. This should correctly display the value.
You could also right click on the textbox and go to expression and say this in the expression popup box:
=FormatNumber(Fields!FieldName.Value,2)
I try and find solution:
I use Expression for value:
=IIf(IsNothing(Fields!FieldName.Value), "", IIf(IsNothing(Fields!FieldName.Value), "-", CInt(Fields!FieldName.Value * 10000) / 10000))

Only allowing one Drilldown in SSRS

It took me hours of searching and putting together piecemeal parts to find the solution to this, so I figured I'd post it on here in the hopes of helping someone else.
The Problem: We need to display a report, with proper grouping and drilldowns. However, we should only allow one group to be drilled down at one time.
SSRS doesn't exactly have robust scripting options - for instance, you can't close other groups "on click" or anything like that. So how do you do it?
In My example i'm using the AdventureworksDW database. I want to have a dataset that includes the total sales for each group and region. My Stored Procedure looks something like this:
SELECT dst.SalesTerritoryGroup,
dst.SalesTerritoryRegion,
SUM(fis.SalesAmount) AS SaleTotal,
DATEPART(YEAR,fis.OrderDate) AS OrderYear
FROM [dbo].FactInternetSales AS fis
INNER JOIN [dbo].DimSalesTerritory AS dst
ON fis.SalesTerritoryKey = dst.SalesTerritoryKey
WHERE fis.OrderDate < #QueryEndDate
GROUP BY
dst.SalesTerritoryGroup,
dst.SalesTerritoryRegion,
DATEPART(YEAR,fis.OrderDate)
UNION ALL /*The ResellerSales table. Same info.*/
From there I added a table with two groups: SalesTerritoryRegion and its parent, SalesTerritoryGroup. I also added a column to the left INSIDE the SalesTerritoryGroup, with an X (this can also be an image if you'd like). This is the "Drilldown" button that we'll use.
Create a string parameter, mine was #ExpandedGroup. Set the Default to an empty string (so that all the groups start out collapsed). Right click on the SalesTerritoryRegion group, or whatever your subgroup is, and go to the visibility tab. Click "Show or Hide based on Expression" and enter something like this:
=iif(Parameters!ExpandedGroup.Value="" or
Fields!SalesTerritoryGroup.Value<>Parameters!ExpandedGroup.Value,True,False)
This statement means: If we haven't opened a dropdown, or if the dropdown isn't the one selected, set hidden to true. Otherwise, false.
Next click on your "X" column to the left of SalesTerritoryGroup or your supergroup. Right click to go to Textbox Properties. Click the action tab. From there select "Go to Report". When you specify a report, make the target itself (For instance, mine is Main). Then, add parameters to the report.
The most important here is ExpandedGroup. The name should be ExpandedGroup, but the value is not just [ExpandedGroup]. Instead, it's an expression:
=IIF(Fields!SalesTerritoryGroup.Value=Parameters!ExpandedGroup.Value,
"",
Fields!SalesTerritoryGroup.Value)
This expression says: If the Group is the same as the Expanded group, make ExpandedGroup an empty string when you load the report. Otherwise, send the TerritoryGroup value. Essentially, this will let us toggle on and off the drilldown (same as you would in the report if you had traditional drilldowns).
Note: Also be sure to pass other parameters! For instance, my query requires a date to exclude some transaction data. If you don't pass this parameter in the "Go to Report" action, then you'll have to enter it again when you DrillDown. This also means you can give yourself even more flexibility when you click a drilldown (changing a chart that's displayed etc.) which is what I'm doing for this project.
Hope it helps someone out! Of course, if there is a more elegant or simpler solution I'd absolutely love to hear it.

SSRS- charts colour coding

I have SSRS solution for SQL 2005 and 2008.
I am showing output in the form of chart- column chart with each column representing different database.
Is there a way to display each column in different color?
Regards
Manjot
You can use a formula to set the colour of each column, but that would work best if you knew what the individual series values ('databases'?) were going to be.
Right-click on your chart and bring up its properties. Now switch to the Data tab and select the first item in the Values list. Click the Edit... button to show the properties for the values (the columns) in your chart. Over on the Appearance tab there's a Series Style... button which takes you to another dialog.
On this new Style Properties dialog, switch to the Fill tab. That's where you set the colour for each of your columns. This can be a formula, so you might make it something like:
=Switch(
Fields!Database.Value = "master", "Blue",
Fields!Database.Value = "msdb", "Red",
"Green")
If you don't know in advance which 'databases' are going to be represented on the chart, this method won't work very well. In that case you might be able to come up with a formula which hashes the database name and comes up with a colour to match. That sounds like an interesting challenge, so add to your question if you need help doing something like that.
Edit
I just got a hash-based-colour-scheme working. It's a pretty nasty piece of code, but it did manage to get me a unique colour for every (string valued) column. Perhaps someone can come up with a better algorithm and post it here. Here's mine:
="#" & left(Hex(Fields!Database.GetHashCode()), 6)
So that's getting the HashCode for the string (a numeric value) and converting it to hex, then taking the leftmost six characters and prepending it with a "#" sign. That gives us a string that looks like a colour value (eg #AB12F0).