SSRS if day = Friday use dataset2 - reporting-services

So I have an SSSRS REPORT with 2 data sets. If the day of the week is Friday I need to show the data in dataset 2 otherwise to use dataset 1. How can I accomplish this? is there a built in expression or function to do this???

You can't set DataSetName property at runtime, but you can select the data you want to return in your dataset based on the week day.
IF DATENAME(WEEKDAY,GETDATE()) = 'Friday'
select categoryDS1 Category, salesDS1 Sales from tableDS1
ELSE
select categoryDS2 Category, salesDS2 Sales from tableDS2
This will work if both SELECT statements have the same columns name
and types.
Let me know if this helps.

You can place a copy of both reports in the report and simply set the visibility for the one you want to show. The expression for the Visibility property for DataSet1 would be:
=IIf(WeekdayName(Weekday(Today)) = "Friday", True, False)
Swap the result for DataSet2.

Related

One dataset controls other in SSRS *.rdl?

I see a mystery behaviour in my *.rdl. I have 2 datasets defined.
I have 4 parameters defined,
StartDate,EndDate, companyid, sitecode
For both datasets,I have defined a select query.
DatasetA uses #Enddate
DatasetB not using it( it uses, startdate, companyid, sitecode)
I want to getrid of #EndDate from datasetA too. So, im using #startdate parameter to define enddate and using that in my sql query.
eg :
DECLARE #eDate AS date =EOMonth(#StartDate)
But after getting rid of this, #EndDate, my second data retrieves less data.(ie: if it should return data from september and october, now it returns only from September)
I checked the rdl, rowgroup/column group everywhere, but there is no any filter defined like that. I see this behaviour, only if i change #EndDate parameter from 1st dataset.
eg:
DECLARE #eDate AS date =EOMonth(#StartDate)
Select ..
Where date>=#StartDate AND date<=#Enddate to date<=#eDate
Is there any place we use parameter as a filter check? If so, how can I check it, where it has been used in the *.rdl?
I figured out the issue. This is due to Lookup function I use between both datasets. So, when dataset2 is trying to retrieve the correct number of rows, dataset1 was controlling it, becuase it didnt return rows for that date.
eg: dataset1 returns September data, while dataset 2 returns September+October data.
Due to lookup function, Dataset1 controls the dataset2's October data.

Can I automatically change the dataset for a tablix based on the current month?

I have a report with 7 datasets and 7 tables all exactly the same except the datasets each have a slightly different where clause
where datepart(DW,[Start Time]) = 2
The idea is to show data for each monday this month in one table and each tuesday in another and so on. So one table uses the monday dataset (above) one uses
where datepart(DW,[Start Time]) = 3
for tuesday and so on. What I really want to do is have the report decide which dataset to use first based on what day the first of the current month was. So this month (April) the 1st was a saturday so I'd like my leftmost table to use the dataset
where datepart(DW,[Start Time]) = 7
Then the one after it to be sunday and so on. But next month (May) I want it to automatically switch to using the monday dataset in the first table as the 1st will be a monday.
Is this possible?
One possibility is to use a sub-report that uses a single dataset. This dataset would have a where clause that takes a parameter
WHERE DATEPART(DW, [Start Time]) = #dayOfWeek
Replace your current 7 tables with 7 copies of the same sub-report but change the parameters to be based on the first day of the month so you first sub-report would have the parameter passed as
=WeekDay(dateserial(Year(now()), Month(now()), "1"))
the second sub report would have the parameter passed as
=WeekDay(dateserial(Year(now()), Month(now()), "2"))
and so on...

Create Single Colum Aggregat IN SSRS Matrix

We have a SSRS Matrix report with the following areas
RowGroup:MonthYear
ColumnGroups:Campaign,Year,Processed
Detail:Sum(Processed)
We have added a single column outside of the ColumnGroup for and expression that will show the increase/decrease of current year processed records over previous year processed records
The data is shaped like this:
lYear, MonthYear, Campaign, Processed
2014, JUL-10, XYZ, 120
2015, JUL-10, XYZ , 60
So the formula is basically CurrentYearProcessed/PreviousYearProcessed which in this example would yield 50%
So how can we specify this when writing the expression?
Just use IIF to filter for the year:
=SUM(IIF(FIELDS!lYear.VALUE = YEAR(GETDATE()), FIELDS!Processed.VALUE, 0) / SUM(IIF(FIELDS!lYear.VALUE = YEAR(GETDATE()) - 1, FIELDS!Processed.VALUE, 0)
This checks your lYear field to see if it's the same as the current year [ YEAR(GETDATE()) ] and sums the Processed field. Then it divides by the previous year's SUM using similar logic.

SUM of a SUM in SSRS 2008

I've this report
Here I make the first sum because I've grouped values from each month (months are "Gennaio", "Febbraio", "Marzo" etc etc.). These values are hidden, but anyway I get the sum and I display the sum for each month.
Then I should make the second sum that use values for each month and display the total for each category. Categories are "TOTALE LAVORI RESTAURO", "TOTALE LAVORI EDILE" etc.)
This is the final sum, where I sum values from each category.
Everything is working well, but now I have to add a "month" parameter to the report that returns sums until a selected month. This parameter changes the sum 1 with this expression:
=Sum(IIf(Fields!mese.Value <= Parameters!mese.Value, Fields!costi.Value, 0))
Now, how should I change expression in SUM2 and SUM3 to work with this parameter?
If I copy that code, ther returns #Error and as far as I know I can't use ReportItems sum.
So any suggestion?
SUM #1 could remain Sum(Fields!costi.Value) because you need to display every months.
i.e.: display GIUGNO even if Parameters!mese.Value = 4 (APRILE).
So you have only to change SUM #2 and #3 because TOTALE LAVORI RESTAURO and TOTALI must show only costi from GENNAIO to Parameters!mese.Value; i.e. if Parameters!mese.Value = 4 display only GENNAIO-APRILE even if we have details about GIUGNO.
The expression gave error because you have NULL value in Fields!costi.Value or Fields!mese.Value: convert this value to zero in your DataSet and you won't have problems.

SSRS Line Chart X-Axis group by Month

everyone. For the life of me I cannot figure out why the X-Axis is pulling 2 dates in each month when I want it to group by each month. In the Values I have:
Value Field =RunningValue(Fields!new_actualsalesfromsplit.Value, Sum, "Chart1_SeriesGroup")
Category Field: =Fields!closedate.Value
Category Groups =Month(Fields!closedate.Value)
Group On =Month(Fields!closedate.Value)
Series Group by ["salesperson']
The chart should have a line for each sales person, and each month should be a cumulative representation of the sales by that person. Thanks for any help.
Set the category field to "=Month(Fields!closedate.Value)", or something similar that will net the results you need. Right now, even though you're grouping by month, you're still telling SSRS to use the atomic data for your X axis, so that's what it's doing.
It may make your task simpler to just add a Calculated Field to your dataset - open the dataset properties window, go to the fields tab, and click "add". Set that field to your month value, use it for grouping and your X axis.