How to make a For Each loop in SSRS Charts - reporting-services

I'm making a charts in SSRS that will display the absence ration per department
so in the chart Data ( Values field ) I have the following expression :
=Sum(Fields!Absence_Hours.Value, "DataSet1") /
Sum(Fields!Worked_Hours.Value, "DataSet1")
This expression works fine when I have only one department chosen, but once I choose more than one department, the program does the following:
(total absence hours of all chosen departments ) /
(total worked hours of all chosen departments )
This returns a single value which makes all my department have the same value in the charts.
How can I make the expression above execute and return results for each department ??
Thanks in advance

There is no need for a for each loop. Drag and drop your department field into the chart datas Category Groups section.
This way the calculation gets done per department in the chart.

Related

get total from two different datasets into a third different tablix ssrs

Here I am, again with another doubt.
Here is my problem:
I have a report where I show ALL the incomes and expenses of the company for the last two days, which i managed by placing a column group grouping the columns by the date
Originally, the report contained a single matrix with both incomes and expenses fed by a dataset that points to the company cube applying the following filter expression
=IIF(Fields!Fecha.Value=Parameters!FechaHoy.Value or Fields!Fecha.Value = Parameters!DiaAnterior.Value,true,false)
FechaHoy = date sent via report parameter input
FechaAyer = date
parameter minus one day
and the filter value set to
=true
So far so good. Today, the upper management decided to split it into three matrix. One for incomes and other two for expenses (one for each expense category), so i startet with this
initial report layout
I created two new datasets for each one of the expense categories with the same filters, and now i'm here
current report layout
THE THING IS... as you can see, there is a "Total Destino" independent table where i have to add the totals of the second and third matrix in the image I added, but, as I already said I have to show the last two days, so i also have to partially add the total of each day (which are column grouped by date)
I'm pretty sured that there's also a better and more efficient way to manage what I did with the three matrices but the main issue which needs your assistance is how do i add the totals of the second and third matrices.
I already tried with
=Sum(Fields!Saldo.Value, "Informacion_Destino") + Sum(Fields!Saldo.Value, "Info_InvTesoreria")
but it adds the two days and repeat it for the two days. I also tried with ReportItems!TextBox + ReportItems!TextBox but the preview loads sends me an error message.
Thanks in advance for your time and help
Like Harry stated already out you can use for your overall total the following expression for the Tesoreria Subtotal + Destino Subtotal :
=ReportItems!TesoreriaSubtotal.Value + ReportItems!DestinoSubtotal.Value
This would give you the overall total for all days. Now if you just have to show the last two days you can add a tablix filter, like this:
'Expression
=IIF(CDate(Fields!YourDate.Value) < DateAdd("d", -2, Now()), True, False)
'Format
=Boolean
'Value
=False

Presentation of data in a SSRS chart

Maybe it's strange because I found nothing in the same kind but.. I'm working on SSRS and I have a chart with many categories (A, B, C, ...) on axis X.
I would like to add, on the same axis, a category which is the sum of categories B,C,D for exemple. Is it possible ?
If yes, please tell me how.
I'd calculate the total from MDX query instead of SSRS. Using something like this:
WITH
MEMBER [Measures].[Gender] AS
[Customer].[Gender].currentmember.PROPERTIES("NAME")
SELECT
{
[Measures].[Internet Sales Count],
[Measures].[Gender]
} ON COLUMNS,
nonempty({
[Customer].[Gender].allmembers
}) ON ROWS
FROM [Adventure Works DW2012]
It shows the Sales Count per Gender and All (sum of all genders).
Once you get it in the query you can plot it in a Bar Chart like an additional category.
Share your MDX with us if you get stuck.
ALTERNATIVE: From SSRS create an additional series to display it as a Chart Line:
Use this expression to calculate the total:
=Sum(Fields!Sales.Value,"DataSetName")
Replace date
Let me know if this helps.

how use average function based in two differents dataset fields ssrs if one depend from the other one

im working with report that visual studio 2010 have, then i have a chart series with four fields planta, date, and densidad, i have to get the average of all the data that densidad has but only when the date is the same for example
Date Densidad
11/05/2015 2
11/05/2015 3
12/05/2015 4
in this case i have two data from 11/05/2015 the only for that date i must get the average that in this case should be 2,5 , ive been looking for an expression that works but i ve found anything, please?
Add a new row group, then go to the group's properties and group by date. In your tablix, add in AVG(Yourdataset!Yourvalue.Value) next to the date. This should group by date.
Your group expression should look like this:
=FormatDateTime(Fields!dates.Value, DateFormat.ShortDate)

SSRS (Column Chart): Showing column bar with Zero(0) lable for non Existing data in bind dataset

I am new to SSRS.
I have created a Aging Column chart by category, by switch case in category group expression like Category group on:
=Switch( Fields!Age.Value>=0 and Fields!Age.Value<=7,1,
Fields!Age.Value>=8 and Fields!Age.Value<=14,2,
Fields!Age.Value>=15 and Fields!Age.Value<=21,3,
Fields!Age.Value>=22 and Fields!Age.Value<=31,4,
Fields!Age.Value>31,6)
My problem is, if Data set bind with chart do not have any row for a particulate category (like "8-14 Days") then chart is not showing data for in with 0 value:
My requirement is if no data available for a age category, Zero(0) value is to be displayed like:
Chart Description are:
Values = Count(id)
Category : Group on
=Switch(Fields!Age.Value>=0 and Fields!Age.Value<=7,1,
Fields!Age.Value>=8 and Fields!Age.Value<=14,2,
Fields!Age.Value>=15 and Fields!Age.Value<=21,3,
Fields!Age.Value>=22 and Fields!Age.Value<=31,4,
Fields!Age.Value>31,6)
Series: No Series.
Thanks to all for your help.
I have achieve my requirement by using Temp SQl Tables, but your guidance is really helpful.
thanks again.
:)

SSRS Reporting multi value parameters

I have a ssrs report, that gives me multiple product's price. My Parameter is not drill down, I have to type in the parameters(since I have large range of product number).
Now my questions is, how can i get the last entered product ( parameter) always appear at the bottom of the report ?. This would help me where to look the latest product in the report.For example I have product numbers like:
abc-234,
abc-570,
ght-908,
Now what I want is that the latest entered product number which is ght-908 to appear at the bottom of the ssrs reports. Right now it gives me the report for the multiple product, but its all over the place and i have to squint my eyes and try to find out where my most recent entered product numbers (parameters) is. I have also tried to stop the parameters to being refreshed everytime i add a product number.
Assuming your parameter name is MyParameter, in report designer (BIDS) just drop a textbox onto report below the data (e.g. Table) and put following expression into its value's formula:
=Parameters!MyParameter.Value.Split(",")(Parameters!MyParameter.Value.Split(",").Length - 1)
it will split the parameter list and grab the last value
Update: here is the screenshot with steps:
And here is the runtime result
This expression works for me:
=Trim(Right(Parameters!Product_Number.Value
, InStr(StrReverse(Parameters!Product_Number.Value), ",") - 1))
Trim might not be strictly necessary but is useful as it will work if the values are split with spaces as well as commas, or not.
For example:
It sounds like you want to order the results of the stored procedure by the order of the product codes as they are typed into the report parameter (which is a comma separated list).
You can return the index (order) of each product code in the parameter by using the Array.IndexOf and Split functions, e.g.
If you have a report parameter called "ProductNumber" and you also have a field called "ProductNumber" returned in your dataset, the following code will return the zero-based index of the Product Number as entered into the parameter list:
=Array.IndexOf(
Split(Parameters!ProductNumber.Value.ToString(), ",")
, Fields!ProductNumber.Value
)
So if abc-234 is the first product number in the parameter list then this code will return 0. If abc-570 is the second product number in the parameter list then this code will return 1, etc.
Assuming the products are listed in a tablix, then I would set the tablix sort expression to the above, which should sort the products into the order specified in the report parameter.