SSRS: Can you have the label of a (pie) chart be both the category AND the Percent - reporting-services

I have a pie chart in SSRS. It contains many categories so it is kinda hard to read. What I would like to do is include the category AND the percent in the label, but I am not sure how to do this.
You can include the category by setting the label to [CategoryName] (this is the default).
You can include the percent by changing that to #PERCENT.
But I cannot seam to figure out how to include both.
Is there a VBA formula that I can add that will give me both?

You can actually just shove #PERCENT into a larger string.
Some simple data:
And a simple chart based on this:
The expression used for the labels is:
=Fields!grp.Value & ": " & "#PERCENT{P2}"
Here {P2} is controlling the formatting. You should be able to adapt to your scenario.
Alternatively, for greater control you can just add the relevant % calculation in the label expression; in the above case this would be:
=Fields!grp.Value
& ": "
& Format(Sum(Fields!val.Value) / Sum(Fields!val.Value, "MyDataSet"), "P2")
Which in this case gives identical results to the above.

As explained here, you can use the #LEGENDTEXT chart keyword to write the text that corresponds to the text of the legend item into the label.

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.

Access Dynamic IIF reference on form

I cant seem to figure out how to reference a combo box value on a form in another textboxs sum iif function. The sample of what I am trying to do is below, with the reference to "TestCombo" the value I want to change based on who is selected. I tried using CHR(34) quotes, and I cant seem to figure it out.
SUM(iif([SaleStatus]= 'Pending' And [SalesAdvisor] = [TestCombo],1,0))
This same function works if I do the following
SUM(iif[SaleStatus]= 'Pending' And [SalesAdvisor] = 'TestAdvisor',1,0))
That led me to believe I needed quotes, which I expected, but that doesn't work either, such as the example below.
SUM(iif"[SalesStauts]= 'Pending' And [SalesAdvisor] = " & chr(39) & [TestCombo] & chr(39) & "",1,0))
Can somebody help me use the combo box as a dynamic reference to the sum iif?
Are you sure that your combo is equal to 'TestAdvisor'? It is quite common to have a numeric bound column and a text display. If you have more than one column in the combo, you will need to refer to the column property to get the text column. If you include the RecordSource for the combo in your question, it will be easy to see.

Way to add a calculated number of X's to a form input?

I have certain product codes with varying number of letters/digits e.g. 53HD6J, HH88WBD3 (varies between 5 to 10 letters/digits). In order for our barcode to scan these correctly there has to be 13 letters/digits. I don't want to make the user to input -XXXX after each code but rather have Access calculate the difference between 13 and the length of the code and fill the remaining with a X's. Is this possible either by vba or and expression?
I currently am using about 6 IIFs in one formula to fill remaining blanks with X's but hoping there is an easier way.
I have a form to enter in the batch number (product code). Once that form is submitted it links to a report that is printed. On the report are those batch numbers (53HD6J, HH88WBD3). The spot I want to have this feature is in a text box right next to the codes where Access determines the length of the codes and computes the remaining X's to add. This is in barcode font so this text box is where the 53HD6JXXXXXXX would go. Hope that clears it up!
So I have that part figured out. My problem now is my barcode font reads the text no matter what and translates it still so barcode shows up when the batch number is blank (I have four spots for batch codes to be inputted). So what I had before was =IIf([Text31]="",""&[Text31]&"","") which seemed to work. Hopefully I can continue this with the new formula. If that's unclear let me know.
**(The "" & & "" is so the barcode can be scanned).
My formula was wrong right above with the IIf. I figured it out! Forgot I had used ' Like "*" '. Thanks!
You can do what you want with String() and Left().
Here is an example from the Access Immediate window:
product_code = "53HD6J"
? product_code & String(13, "X")
53HD6JXXXXXXXXXXXXX
? Left(product_code & String(13, "X"), 13)
53HD6JXXXXXXX
Based on the update to your question, I think you can use that approach for the Control Source of a text box where you want to display the "expanded" product code.
Pretend your report has a text box named txtProduct_code where the raw product code, such as 53HD6J, is displayed. And there is a second text box where you want to display that value with the required number of X characters (53HD6JXXXXXXX).
Use this as the Control Source property of that second text box:
= Left([txtProduct_code] & String(13, "X"), 13)
Alternatively, you could make it a field expression in the report's Record Source query.
SELECT
product_code,
Left(product_code & String(13, "X"), 13) AS expanded_product_code
FROM YourTable;

How to percentage and count in SSRS Pie Chart

I have a Pie chart generated using SSRS. I would like to Show both Count and percentage in the Pie chart.
Right now, I am able yo show the count in pie charts as well as in the report.
I want to show the name of the partition and also the percentage directly pointed out.
Example :
ALD 38% 56
please help me withe properties to do it.
I'm using VS 2008
1-right click on chart and select "show data label"
2-right click on label an select "series label properties"
3- general -> label data -> set this value = "#PERCENT (#VALY)"
4- it will be like this screenshot
write down an expression on series label data like -
=Sum(Fields!DATA.Value, "Chart1_SeriesGroup1") & "("
& Sum(Fields!DATA.Value, "Chart1_SeriesGroup1") * 100 /Sum(Fields!DATA.Value, "DataSet1")
& "%)"
Here Chart1_SeriesGroup1 is the group name if you look at series group setting
Here DataSet1 is the name of Dataset
Here is the final output
Cheers :-)
In the label Properties type "#PERCENT" in Label Data
This can be used on its own or in conjunction with the other value itself by adding "#PERCENT(#VALY)"
Place this in quotes if you are trying to concat other values with it. For instance, this would show the label with the accompanying percent below
=First(Fields!Data.Value, "Chart_Group") & vbcrlf & "#PERCENT"
Where "Chart_Group" is the name of the grouped on field

SSRS - Custom Pie Chart Legend

I need some assistance with the following, I have a pie chart with 1 series(Area) and 1 value(Spend)
Now my legend atm is just displaying my Area, but I wanted to add or custom my legend to display the Area and a percentage of the spend. e.g. Los Angeles - 34.5%
How and what should I do to achieve this and what am I doing wrong?
But using this in my custom legend:
#AXISLABEL (#PERCENT {P1})
If you're using multiple values and concatenating them together, you will need to use an expression, i.e =..., and use & to combine the different elements.
In your case this will be something like:
="#AXISLABEL" & " - " & "#PERCENT{P1}"
Edit after comment
The value displayed by #AXISLABEL will depend on what you've defined as the label value under the Category Group properties:
That said, if you're just looking to explicitly display the Area field, why not just change the expression to look at that directly instead of implicitly through the #AXISLABEL:
=Fields!Area.Value & " - " & "#PERCENT{P1}"
This seems like the easiest option based on what you describe.