SSRS Matrix columns show currrent month - reporting-services

I'm stuck with a problem in SSRS 2012 that maybe is very simple:
I have a matrix with a group row (employee) and a group column (last 12 months); the values are COUNT(practicesDone) - i.e. the amount of practices worked.
I want the matrix to show an extra column on the right (after all the columns of the months, and clearly outside the column group) with again the number of practices for the current month.
Is it possible to achieve that?
thank you in advance!

You can do this, it's pretty simple.
I have assumed that your dataset contains a column that has a date for each entry and that the data returned only covers 12 months so the same month would not appear for different years. If your data does have multiple years, look at the second expression below.
Right-click your month column and then to "Insert Column --> Outside Group - Right"
Now set the expression for the text box to
=COUNT(IIF(MONTH(Fields!myDateColumn.Value) = MONTH(TODAY()), 1, Nothing))
You could swap COUNT for SUM and it should do the same thing but either will work.
All we are doing here is comparing the all data in scope which, due to the placement of the text box means the scope is the entire rowgroup. Then for all that data, check if the month matches the current month, if it does set it to 1 is not set it to nothing then count/sum all results. Count conveniently ignores 'nothing'.
If you data covers more than 12 months then you can still do this but you'll have to add a bit more to handle years and months like this.
=COUNT(
IIF(
MONTH(Fields!myDateColumn.Value) = MONTH(TODAY())
AND YEAR(Fields!myDateColumn.Value) = YEAR(TODAY()),
1,
Nothing
)
)

Related

Calculate difference between multiple group columns in SSRS Report

First post in stackoverflow - so forgive me if I don't get this right. I have an SSRS report with a matrix which groups Quantity, Total Spend and Average Cost by part number for each year. Part Number and description down the left and the the years along the top. I want to add a delta column in each year after the first year which shows the change in price from the previous year. I have seen examples of how to get the difference between first and last year - but not the difference between each year and the previous one. I have hidden the delta column for the first year - no would love some guidance on how to calculate the difference in cost.
So from the image below the first row in the delta column under FY2019 would show -€0.01 as price has reduced from 0.59 to 0.58.
You haven't explained how if Avg. Cost is calculated in your report but I'm assumming it's just something like =SUM(Fields!Spend.Value) / SUM(Fields!Qty.Value)
You've not shown your report design so I can't tell what your row/column groups are called but I'll assume you have rowgroup by Part and one by Year. Let's assume your column group name is PeriodID so it's the same as my demo report.
In this case you can use the PREVIOUS() function to get the previous values to compare against.
I set up a similar report to demonstrate. As you can see in my case the year column is grouped using a columngroup called PeriodID
The expressions highlighted are as follows.
Price. This is just Cost/Qty =SUM(Fields!Cost.Value)/SUM(Fields!Qty.Value)
lastprice. This is just for illustration and debugging. It uses the PREVIOUS() fucntion to get the previous year's data
=Previous(Sum(Fields!Cost.Value), "PeriodID") / Previous(Sum(Fields!Qty.Value), "PeriodID")
Note that "PeriodID" is the name of the column group (case sensitive). This is scope for the previous function so it know to get data from the previous column group.
delta. This is the final output. It's just the current "Price" expression minus the "lastprice" expression.
=(Sum(Fields!Cost.Value) / Sum(Fields!Qty.Value)) - (Previous(Sum(Fields!Cost.Value), "PeriodID") / Previous(Sum(Fields!Qty.Value), "PeriodID"))
The final output looks like this (I've not hidden the column for the first column group or hidden last price, just so you can see it working). Also, if you see slight differences in the delta column compared to what you might expect, it's just down to the fact that the numbers are formatted to 2 decimals but my test data is up to 14 decimals.

Calculate the average in SSRS 2016

I am using SSRS 2016 application to pull data from SharePoint list.
My task is to calculate the average DaysUsed and the average Percentage from a column.
It is a Matrix report which has two columns:
Sum(Fields!Days.Value)
Sum(Fields!Percentage.Value)
The task is to show the average days and average percentage.
I have tried the =Avg(Fields!Days.Value) but this shows wrong result.
UPDATE
Yes, the matrix is grouped by the Month to show each relevant month.
See the screenshot below what I have tested so far.
The DaysUsed is a calculated between 2 fields [FromDate] and [UntilDate] by summarising the total days minus the weekends. see below:
=(DateDiff(DateInterval.day,CDate(format(Fields!FromDate.Value,"MM-dd-yyyy")), CDate(format(Fields!UntilDate.Value,"MM-dd-yyyy")))+1)
- (DateDiff(DateInterval.WeekOfYear,CDate(format(Fields!FromDate.Value,"MM-dd-yyyy")), CDate(format(Fields!UntilDate.Value,"MM-dd-yyyy")))*2)
- IIF(Weekday( CDate(format(Fields!FromDate.Value,"MM-dd-yyyy")),1) = 1,1,0)
- IIF(Weekday( CDate(format(Fields!FromDate.Value,"MM-dd-yyyy")),1) = 7,1,0)
- IIF(Weekday( CDate(format(Fields!UntilDate.Value,"MM-dd-yyyy")),1) = 1,1,0)
- IIF(Weekday( CDate(format(Fields!UntilDate.Value,"MM-dd-yyyy")),1) = 7,1,0)
Furthermore, the [DaysUsed] row then consists of IIF(value is null then show 0 otherwise show the total value of days used).
=IIF(IsNothing(Sum(Fields!Days.Value)), "0", Sum(Fields!Days.Value) )
Sum(Fields!Days.Value)/CountRows()
Shall give you average days. Similarly goes for others as well.
If you has a field called Fields!Days.Value, I guess your data in the screenshot is already grouped by month. This means the expression
=Avg(Fields!Days.Value)
gives you the average over all Days (sum of all days / count of all days).
If you want to use the grouped values (by mounth) you either can use the following expression when you are inside the scope (the monthly socpe; indicated by the brackets on the most left side on your tablix)
=Sum(Fields!Days.Value) / Count(Fields!Days.Value)
If you are not in the scope you have to tell the tablix that is should use your monthly grouping. For this you can use the following:
=Sum(Fields!Days.Value, "YourMonthGroupName") / Count(Fields!Days.Value, "YourMonthGroupName")

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

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)

How can I add an aggregate percentage to an SSRS report based on two specific columns in a matrix?

I am somewhat new to SSRS and I have built a matrix report that looks fairly simple:
Supplier [AccDate]
[SupplierName] Sum(PurchasingCredit)
Total <<Expr>>
The actual report shows month-by-month sales data for a year in addition to Current YTD and Previous YTD columns (joined via UNION clause in base query) in addition to a column showing Year-over-Year % as difference between the Current YTD and Previous YTD columns (also joined via union).
I was able to apply a dynamic format to the Year-over-Year column using the following expression in the Format property to show the YOY column as a percentage and the others as dollar amounts:
=IIF(Fields!AccDate.Value <> "YOY", "'$' #,0.00;'$' -#,0.00", "#,0.00 %;-#,0.00 %")
The last thing I need to do is to show the column totals, which are working for each column with the exception of the year-over-year percentages using the following:
=IIF(Fields!AccDate.Value <> "YOY", SUM(Fields!PurchasingCredit.Value), 0)
In the year-over-year (YOY) column, a sum of percentages doesn't make sense: I need it to recalculate this value based on the sums of the "CYTD" and "PYTD" columns, but I can't seem to figure it out. Any help would be greatly appreciated. I am guessing it is probably an application of scope, but the MS articles that attempt to explain this are very confusing.