SSRS Expression Month at a glance
I have a report that I am trying to regress the payment sums out month by month. I know how to do this in SQL, but no idea in SSRS. Below is what I would like the table to look like.
Year Month
Total Payments Month1 Month2 Month 3
2012 1
10,000.00 2000.00 2000.00 6000.00
2
15,000.00 5000.00 1000.00 9000.00
And this would go on. I have the report built to drill down by year and month and show the sum of the payments. What I can not figure out is how to break out the payments collected month by month. I hope this makes sense.
Okay after much playing with this I have starting having success. This is what I want to do.
=sum(IIF(Fields!MPaidDate.Value = Month(Dateadd(DateInterval.Month, 1, Fields!Date_Recieved.Value))
and Fields!YPaidDate.Value = Year(Fields!Date_Recieved.Value), Fields!Amount_Paid.Value,0))
My month 1 column I left out the dateadd and I got back the right values. But when I try to add 1 month with date add it returns false.
Why do you need to write conditional expressions like this?Isnt it enough to bring MONTH(datecolumn) as a field in your dataset and use matrix control in your report? Add year to rowgroup and Month to column group to get data split up into monthwise. And inside
data part add three columns to show your measure value ie.#of orders ,
Balance
& Total Paid
Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs
Similar Messages
-
Hi All;
I have a field called createdon
Using this field i need to create the SSRS expression for the table as below
Any help much appreciated
Thanks
Pradnya07use expressions as below
assuming this is to be done in SSRS
Today
=COUNT(IIF(
DateDiff(DateInterval.Day,Cdate("01/01/1900"),Fields!createdon.Value) = DateDiff(DateInterval.Day,Cdate("01/01/1900"),Now()),Fields!YourRequiredField.Value,Nothing))
Yesterday
=COUNT(IIF(
DateDiff(DateInterval.Day,Cdate("01/01/1900"),Fields!createdon.Value) = DateDiff(DateInterval.Day,Cdate("01/01/1900"),Now())-1,Fields!YourRequiredField.Value,Nothing))
LastWeek
=COUNT(IIF(
DateDiff(DateInterval.Week,Cdate("01/01/1900"),Fields!createdon.Value) = DateDiff(DateInterval.Week,Cdate("01/01/1900"),Now())-1,Fields!YourRequiredField.Value,Nothing))
Last fortnight
=COUNT(IIF(
(DateDiff(DateInterval.Week,Cdate("01/01/1900"),Fields!createdon.Value) = DateDiff(DateInterval.Week,Cdate("01/01/1900"),Now())-1)
Or (DateDiff(DateInterval.Week,Cdate("01/01/1900"),Fields!createdon.Value) = DateDiff(DateInterval.Week,Cdate("01/01/1900"),Now())-2),Fields!YourRequiredField.Value,Nothing))
Last Month
=COUNT(IIF(DateDiff(DateInterval.Month,Cdate("01/01/1900"),Fields!createdon.Value) = DateDiff(DateInterval.Month,Cdate("01/01/1900"),Now())-1,Fields!YourRequiredField.Value,Nothing))
Year To Date
=COUNT(IIF(DateDiff(DateInterval.Year,Cdate("01/01/1900"),Fields!createdon.Value) = DateDiff(DateInterval.Year,Cdate("01/01/1900"),Now())
And
DateDiff(DateInterval.Day,Cdate("01/01/1900"),Fields!createdon.Value) <= DateDiff(DateInterval.Day,Cdate("01/01/1900"),Now()),Fields!YourRequiredField.Value,Nothing))
Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs -
Hello,
Is there anyway to default to the first day of the month in a SSRS expression. I'm looking to do the reverse of the EOMONTH() function.
The date value is coming from a parameter @BegDate and formatted YYYY-MM-DD. So if the parameter is set to 2015-08-31 it would show 2015-08-01
Any information would be greatly appreciated.
xI ended up using the following:
DateSerial(Year(Parameters!BegDate.Value), Month(Parameters!BegDate.Value), 1
x -
How Get last five quarters data using ssrs expression
Hi All,
i have an ssrs report where i have to get last five quarters data and also last five months data when i select quarterly/monthly parameter.....
is there any possibilty that we can get this using ssrs expression
any help please.........Hi Mr.SMK,
According to your description, there is an SSRS report, you want to create a parameter, when you select quarterly, data of last five quarters will be displayed. If you select monthly, data of last five months will be displayed. If that is the case, please
refer to the following steps:
1. In design surface, in Report Data pane, right-click Parameters and click Add Parameter.
2. Type parameter name and prompt, set Data Type to Date/Time.
3. Click Available Values in left pane, select Specify values.
4. Click Add button, in Label text box, type Quarterly, then click (fx) button and type the expression like below:
=DateAdd("q",-5,Today())
5. Click Add button, in Label text box, type Monthly, then click (fx) button and type the expression like below:
=DateAdd("m",-5,Today())
6. Right-click the dataset used to retrieve data for the report and open Dataset Properties dialog box.
7. Click Filters in left pane, click Add button, select Data from Expression drop down list, set Operator to >=, in Value text box, type [@ParameterName].
The following screenshots are for your reference:
If you have any more questions, please feel free to ask.
Thanks,
Wendy Fu
Wendy Fu
TechNet Community Support -
Hi,
I am unable to convert the below ssrs expression to sql query. can you guys help.
-- IIF(Parameters!parameter1.Value Is Nothing,
-- " 3>2 ",
-- "column1 NOT LIKE
-- Replace(IIF(Left(Parameters!parameter1.Value, 1) = "'",
-- Parameters!parameter1.Value,
-- "'" & Replace(Parameters!parameter1.Value, "'", "''") "'"),
Thanks.Thank you for your response Carnegie,
I actually have two stored procedures as below. (columns and joined tables are excluded)
I need to change the dates of @DateFrom and @DateTo parameter, I am passing @DateFrom_FD and @DateTo_LD as well.
CREATE ROCEDURE [dbo].[Test]
(@DateFrom
SMALLDATETIME
, @DateTo
SMALLDATETIME
, @program
VARCHAR(MAX))
AS
DECLARE
@DateFrom_FD
SMALLDATETIME
, @DateTo_LD
SMALLDATETIME
SET @DateFrom_FD = DATEADD(MONTH,DATEDIFF(MONTH,0,@DateFrom),0)
SET @DateTo_LD = DATEADD(DAY,-1,DATEADD(MONTH,DATEDIFF(MONTH,0,@DateTo)+1,0))
SELECT
DimDate.[Year]
, DimDate.[Month]
, DimDate.PK_Date
, CustomerID
FROM DimDate
WHERE DimDate.PK_Date BETWEEN @DateFrom_FD AND @DateTo_LD
Now I am using one of the SP as a main report and the other SP as a subreport.
In order to configure the main report and the subreport, I believe that I need to link them with parameters.
However, in the parameters of subreport properties, the option given are only @DateFrom and @DateTo.
No @DateFrom_FD AND @DateTo_LD
Therefore, I am thinking to use expressions to convert @DateFrom and @DateTo the same way I did in SQL.
I am not sure if this works....but this is the only thing that I could think of.
Thank you,
YJB5151 -
How can I convert the below two queries in SQL to SSRS expression?
1) DATEADD(MONTH,DATEDIFF(MONTH,0,@DateFrom),0)
2) DATEADD(DAY,-1,DATEADD(MONTH,DATEDIFF(MONTH,0,@DateTo)+1,0))
Thank you,Thank you for your response Carnegie,
I actually have two stored procedures as below. (columns and joined tables are excluded)
I need to change the dates of @DateFrom and @DateTo parameter, I am passing @DateFrom_FD and @DateTo_LD as well.
CREATE ROCEDURE [dbo].[Test]
(@DateFrom
SMALLDATETIME
, @DateTo
SMALLDATETIME
, @program
VARCHAR(MAX))
AS
DECLARE
@DateFrom_FD
SMALLDATETIME
, @DateTo_LD
SMALLDATETIME
SET @DateFrom_FD = DATEADD(MONTH,DATEDIFF(MONTH,0,@DateFrom),0)
SET @DateTo_LD = DATEADD(DAY,-1,DATEADD(MONTH,DATEDIFF(MONTH,0,@DateTo)+1,0))
SELECT
DimDate.[Year]
, DimDate.[Month]
, DimDate.PK_Date
, CustomerID
FROM DimDate
WHERE DimDate.PK_Date BETWEEN @DateFrom_FD AND @DateTo_LD
Now I am using one of the SP as a main report and the other SP as a subreport.
In order to configure the main report and the subreport, I believe that I need to link them with parameters.
However, in the parameters of subreport properties, the option given are only @DateFrom and @DateTo.
No @DateFrom_FD AND @DateTo_LD
Therefore, I am thinking to use expressions to convert @DateFrom and @DateTo the same way I did in SQL.
I am not sure if this works....but this is the only thing that I could think of.
Thank you,
YJB5151 -
Does anyone else miss the month-at-a-glance feature from the old version of Reminders app? I wish Apple would bring that feature back. It made it very convenient to schedule for the future.
You can send feedback and let Apple know
http://www.apple.com/feedback/ -
Pass function name as parameter in SSRS expression
I have a function (GetColumnFieldName) which returns string datatype
Now I want to use this function in below SSRS expression
=Code.GetDisplay("FirstName",Parameters!SelectedCols.Value,Parameters!DisplayCols.Value)
At the above expression I want to replace "FirstName" with function GetColumnFieldName which returns the same "FirstName".
Please suggest.Hi Jajatibabu,
If I understand correctly, you want to use GetColumnFieldName function which returns a field name to replace the “FirstName” in the expression you post.
If in this scenario, we can directly use Code.GetColumnFieldName(parameters) to replace the “FirstName” like below:
=Code.GetDisplay(Code.GetColumnFieldName(parameters),Parameters!SelectedCols.Value,Parameters!DisplayCols.Value)
Note that we should type the correct parameters in the GetColumnFieldName function.
If there are any misunderstanding, please elaborate the issue for further investigation.
Thanks,
Katherine Xiong
If you have any feedback on our support, please click
here.
Katherine Xiong
TechNet Community Support -
SSRS Expression for Conditional Filtering using the "IN" operator
Hello,
I need to filter my dataset based on a parameter:
If Period= 1 then Week must be in (W1, W2, W3), Else Week must be in (W10, W20, W30)
I tried using the "IN" operator but don't know how to create the expression for the "Value" field. I tried the following:
iif(Parameters!Period.Value = 1,
"W1, W2, W3",
"W10, W20, W30")
But it doesn't work.
Expression: Week
Operator: IN
Value: ???
Any help would be highly appreciated!Hi,
Use split function.
See this expression: IIF(Parameters!Period.Value = 1, SPLIT("W1,W2,W3",","), SPLIT("W10,W20,W30",","))
http://social.msdn.microsoft.com/Forums/sqlserver/en-US/8da78c9b-7f0c-42f1-a9c4-82f065f317c9/using-the-in-operator-in-ssrs-expressions
Thanks Shiven:) If Answer is Helpful, Please Vote -
Hi All,
Below is the my table with SSRS expressions marked as A and B
Expression A gets the serial number 1, 2, 3 etc
I need to get expression A/B
Any help on this much appreciated
Thanks
Pradnya07It's look like you want B/A, not A/B.
You can try couple things. If you are allowed to use ReportItems and refer to the textbox value, then simply use this:
=ReportItems!textboxnameforB.Value / ReportItems!textboxnameforA.Value
If that gives you error as far as not allow to use ReportItems, then try create a divide function in custom code and then pass the value to it.
Public Function Divide(Num1 as double, Num2 as double) AS double
IF IsNothing(Num1) Or IsNothing(Num2) Or Num1 = 0 Or Num2 = 0 Then
Divide = 0
ELSE
Divide = Num1 / Num2
END IF
End Function
Then, simply use this in the textbox you want the value:
=code.Divide(RunningValue(Fields!new_programmeoutputid.Value,CoutDistinct, "new_outputs"),RunningValue(Fields!new_claimmonthid.Value,CountDistinct,
Nothing))
If that still does not work, then try to bring these values in the query itself.
good luck. -
Hi,
Can anyone tell me how to use OR in an SSRS expression?
I would like to set the BorderStyle Left (& Right) property to "None" for two rows so I need to
use an OR (6 or 9)
This is what I have so far:
=IIf(RowNumber(nothing)=6,"None","Default")Hi,
Try Below,
=Switch(RowNumber(nothing)=6 ,"None",RowNumber(nothing)=9,"None")
OR
=IIf(RowNumber(nothing)=6 OR RowNumber(nothing)=9,"None","Default")
OR
=IIf(RowNumber(nothing)=6,"NONE",IIf(RowNumber(nothing)=9,"NONE","Default"))
Thanks -
Hello, Expert,
Could you please help me with the following problem? Thanks in advance!
I have designed the matrix report (SSRS 2012) with database table structure looks like below.
Week
Version
Count
Week1
V1.1
4000
Week1
V1.2
4000
Week1
V1.3
4000
Week2
V1.1
3000
Week2
V1.2
3000
Week2
V1.3
3000
Week3
V1.1
2000
Week3
V1.2
2000
Week3
V1.3
2000
Week4
V1.1
1000
Week4
V1.2
1000
Week4
V1.3
1000
The matrix report displays like below. Column grows based on no of Week in the table.
Week1
Week2
Week3
Week4
V1.1
4000
3000
2000
1000
V1.2
4000
3000
2000
1000
V1.3
4000
3000
2000
1000
What I want to do now is: instead of the Count values, I need to calculate the percentage of each week over the
Count in Week1 so that each cell displays Count(Week2)/Count(Week1), Count(Week3)/Count(Week1), etc. What is the SSRS expression for that? I’m new to SSRS, Please help!Heidi,
Thank you so much for your reply and solution! Now I know how to get the first field in a group. But I can't apply your solution directly just yet because in order to explain my problem I simplified my data structure. My real data structure has a nested
group like this:
Week VersionMajor VersionMinor Count
Week1 V1 V1.1 2000
Week2 V1 V1.1 1500
Week3 V1 V1.1 800
Week1 V1 V1.2 1000
Week2 V1 V1.2 500
Week3 V1 V1.2 200
Week1 V1 V1.1 2000
Week2 V1 V1.1 1500
Week3 V1 V1.1 800
Week1 V1 V1.2 1000
Week2 V1 V1.2 500
Week3 V1 V1.2 200
Here is the query for the above data:
SELECT 'Week1' AS Week, 'V1' AS VersionMajor, 'V1.1' AS VersionMinor, 2000 AS Count
UNION ALL
SELECT 'Week2' AS Week, 'V1' AS VersionMajor, 'V1.1' AS VersionMinor, 1500 AS Count
UNION ALL
SELECT 'Week3' AS Week, 'V1' AS VersionMajor, 'V1.1' AS VersionMinor, 800 AS Count
UNION ALL
SELECT 'Week1' AS Week, 'V1' AS VersionMajor, 'V1.2' AS VersionMinor, 1000 AS Count
UNION ALL
SELECT 'Week2' AS Week, 'V1' AS VersionMajor, 'V1.2' AS VersionMinor, 500 AS Count
UNION ALL
SELECT 'Week3' AS Week, 'V1' AS VersionMajor, 'V1.2' AS VersionMinor, 200 AS Count
UNION ALL
SELECT 'Week1' AS Week, 'V1' AS VersionMajor, 'V1.1' AS VersionMinor, 2000 AS Count
UNION ALL
SELECT 'Week2' AS Week, 'V1' AS VersionMajor, 'V1.1' AS VersionMinor, 1500 AS Count
UNION ALL
SELECT 'Week3' AS Week, 'V1' AS VersionMajor, 'V1.1' AS VersionMinor, 800 AS Count
UNION ALL
SELECT 'Week1' AS Week, 'V1' AS VersionMajor, 'V1.2' AS VersionMinor, 1000 AS Count
UNION ALL
SELECT 'Week2' AS Week, 'V1' AS VersionMajor, 'V1.2' AS VersionMinor, 500 AS Count
UNION ALL
SELECT 'Week3' AS Week, 'V1' AS VersionMajor, 'V1.2' AS VersionMinor, 200 AS Count
And my matrix table looks like this:
What I need to do is to calculate the percentage of each week over week1 for
1) V1 Total
2) V1.1
3) V1.2
I can't use your solution directly because I need to apply Sum function for each cell and the Sum function gives me error when I try to use it on the denominator
First(Fields!Count.Value,"VersionMinor"). If you could help me further to get to the final solution, I'd really appreciate it!!
Happy New Year! -
SSRS expression for grouping minutes
Hi All,
Can you please help me to write an SSRS expression to group minutes
=SWITCH(
Fields!TotalHours.Value = 0
and 240,
"0 To 4 hrs",
Fields!TotalHours.Value = 241
and480,
"5 To 8 hrs",
Fields!TotalHours.Value = 481
and720,
"9 To 12 hrs",
Fields!TotalHours.Value = 721
and960 ,
"13 To 16 hrs",
Fields!TotalHours.Value = 961
and1200,
"17 To 20 hrs",
Fields!TotalHours.Value = 1201
and12000000,
"More than 20 hrs"
Any help much appreciated
Thanks
Pradnya07Try this...
= SWITCH ( Fields!TotalHours.Value <= 240, "0 to 4 Hrs",
Fields!TotalHours.Value <= 480, "5 to 8 Hrs",
Fields!TotalHours.Value <= 720, "9 to 12 Hrs",
Fields!TotalHours.Value <= 960, "13 to 16 Hrs",
Fields!TotalHours.Value <= 1200, "17 to 20 Hrs",
Fields!TotalHours.Value > 1200, "More than 20 Hrs") -
Hi all,
I am facing some issue with ssrs expression.
I used below expression to show sum of budget.
=Sum( CDbl(Fields!Budget.Value))
When I preview the report it shows #Error in that textbox.
Please help me to fix this one , I am not getting where its breaking..
Thanks
RohitHi Rohit,
According to your description, you want to sum the [EstimatedCostField] with an expression.
In your scenario, since the [EstimatedCostField] is budget which you want to perform sum calculation, you should specify the sum expression like below:
=Sum(CDbl(Fields!EstimatedCostField.Value))
If issue persists, please run the report in the BIDS then check the warning message in output to see the detail information about the #Error. Besides, please also share the report design for our analysis.
If you have any question, please feel free to ask.
Best regards,
Qiuyun Yu
Qiuyun Yu
TechNet Community Support -
SSRS Expression Current month in a Fiscal calendar dimension from a SSAS cube
How to create an expression for a default SSRS parameter to a SSAS cube when using i Fiscal Year calendar - and where I want to show current Calendar month and year (for example February 2014)
This is an example of my Time dimension for February 2014:
[Time].[FiscalYMD].[Fiscal_Year].&[2013].&[10]
The fiscal calendar goes from May - May - which means that April 2014
would look like this:
[Time].[FiscalYMD].[Fiscal_Year].&[2013].&[12]
and May 2014 would look like this:
[Time].[FiscalYMD].[Fiscal_Year].&[2014].&[01]
Please adviseHi HCMJ,
To represent the fiscal calendar, you shift the current date by 4 months back. Then you can do:
="[Time].[FiscalYMD].[Fiscal_Year].&[" & Year( DateAdd( "m", -4, Today() ) ) & "].&[" & Month( DateAdd( "m", -4, Today() ) ) & "]"
It just gets the year and month of '4 months ago'. I have not tested it, but I guess it should work.
Regards
Andrew Borg Cardona
Maybe you are looking for
-
How to put ituness movies onto separate hard drive?
I have just started to downloads films from the itunes store, however I don't want to clog up my Mac's hard drive. Is there any way to put the Movies onto an external hard drive? Please bear in mind I watch the films by streaming to Apple TV.
-
Can't transfer videos to itunes??
hey all i just wanted to know if there was a way (if its legal) to transfer videos to itunes that you didnt buy off itunes...like i have dvds of some of my fav movies that i would like to put on my touch without having to buy them in itunes...is ther
-
Rmi rebind's problem,dynamic rebind object!
hi,everyone I have a problem,i know a class's name and this class have implement remoteobject, what can i rebind this class on the RMI registry . I write code like this: Class temp = Class.forName("Test"); Naming.rebind("test",temp.newInstance()); th
-
3.6 wasupdated today and my home page comes up blank and i can't get on any site
3.6 was updated today. i can't access my home page or any internet site == This happened == Every time Firefox opened == 3.6 was updated automatically today. == == User Agent == Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; G
-
Problem with CCM view assignement
Hi all, I have the next scenario, SRM an CCM working properly, I publish the master catalog, and I can make a shopping cart taking products from it, I create tree view's and assign one to the role of the user that make the SC, but there's no restrict