Here is my formula
Deviation=(Today- yesterday)/yesterday
Need the value in %
If today is 0, then the value should be -100%(negative deviation)
If yesterday is 0, then the value should be +100%(positive deviation)
Issue:
1.Getting NaN if both today and yesterday are 0. Expected -100%
2.And infinity if yesterday is zero. Expected +100%
Assuming your expression looks like that below
= (Fields!myvalue.Value-Previous(Fields!myvalue.Value)) / Previous(Fields!myvalue.Value)
You can use switch to customize the output based on conditions when current or previous value is 0
Adjust your expression to look like that below
= Switch(
Fields!myvalue.Value=0 AND Previous(Fields!myvalue.Value)=0, -1,
Previous(Fields!myvalue.Value)=0, 1,
True, (Fields!myvalue.Value-Previous(Fields!myvalue.Value)) / Previous(Fields!myvalue.Value)
)
Related
Hello all I am writing the following condition to hide the textbox based on a condition but some how it is not working
<Hidden>=IIF(Format(Fields!VisitDt.Value,"MM/dd/yyyy")>= Format("2022-01-08","MM/dd/yyyy"),True,False)</Hidden>
So what should be the correct way to do this can some one let me know
If VisitDt is actually a date field then you can do something like
=IIF(Fields!VisitDt.Value >= DATESERIAL(2022, 1, 8) , True, False)
You could actually simply if further as the Hidden property only requires an expression that evaluates to True or False so you could simply use
=Fields!VisitDt.Value >= DATESERIAL(2022, 1, 8)
There is no need for the IIF
Given this data: Complete Dataset
I only want to get the Total_AR of those TransactionYrMonth=ParameterPeriod so I produced it using this code:
=IIF(
IsNothing(Sum(Fields!Total_AR.Value)),0,
Sum(IIF(Cdate(Fields!TransactionYrMnth.Value)=Cdate(Parameters!Period.Value),
Fields!Total_AR.Value,0)
)
)
From there, I got this dataset:
Filtered Dataset
Now, what I need to do is to get the sum of the first 3 service months starting from January to March that is equal to the latest transaction month which is April.
So the sum should be equal to $204,329 + -$96,640 + -$259,008 = -$151,319
To make it possible, I tried to use a code like this:
=Sum(IIF(
Cdate(Fields!TransactionYrMnth.Value)=Cdate(Parameters!Period.Value) And (
Cdate(Fields!ServiceYrMnth.Value)=DateAdd(DateInterval.Month, -3, CDate(Parameters!Period.Value)) Or
Cdate(Fields!ServiceYrMnth.Value)=DateAdd(DateInterval.Month, -2, CDate(Parameters!Period.Value)) Or
Cdate(Fields!ServiceYrMnth.Value)=DateAdd(DateInterval.Month, -1, CDate(Parameters!Period.Value))), Fields!Total_AR.Value,0
))
I have no luck producing it. I even got an error saying
‘Textbox11.Paragraphs[0].TextRuns[0]’ contains an error: [BC30516] Overload resolution failed because no accessible 'IIf' accepts this number of arguments.
Anyone, please help?
I got a solution already using this code:
=Sum(IIF(
Cdate(Fields!TransactionYrMnth.Value)=Cdate(Parameters!Period.Value) And
CDate(Fields!ServiceYrMnth.Value) >= DateAdd(DateInterval.Month, -3, CDate(Parameters!Period.Value)) And
CDate(Fields!ServiceYrMnth.Value) <= DateAdd(DateInterval.Month, -1, CDate(Parameters!Period.Value)), Fields!Total_AR.Value, 0
)
)
SQL Server 2012 - SSRS Questions
I currently have a Pie chart that shows the number of deliveries as a percentage on whether they are late, on time or early. What I am trying to do is use an Expression in the Chart Series Labels "Visible" property to hide the label if it is 0 on the chat. Of note in the table this value is returned as 0.00 I have tried using various SWITCH and IFF Statements to do this but nothing seems to work and its likely I am getting the syntax wrong, can anyone help?
Table Values
TotalIssued Early Late OnTime EarlyPerc LatePerc OnTimePerc
6, 0, 4, 2, 0.00, 66.67, 33.33,
=SWITCH(
(First(Fields!EarlyPerc.Value, "EstimatesIssued") = 0),false,
(First(Fields!LatePerc.Value, "EstimatesIssued") = 0),false,
(First(Fields!OnTimePerc.Value, "EstimatesIssued") = 0),false,
true)
Thanks
Try:
=SWITCH(
First(Fields!EarlyPerc.Value, "EstimatesIssued") = 0,false,
First(Fields!LatePerc.Value, "EstimatesIssued") = 0,false,
First(Fields!OnTimePerc.Value, "EstimatesIssued") = 0,false,
true,true)
UPDATE:
If you have one field per percentage and your dataset returns one row always, you have to select each serie in the ChartData window and press F4 to see properties window.
In properties window set for EarlyPerc Visible property:
=IIF(Fields!EarlyPerc.Value=0,False,True)
And so on for the next two series you have (LatePerc and OnTimePerc).
Let me know if this helps.
I'm trying to set my results for an expression in SSRS to return 0 if the datediff results is negative. my expression is:
=DateDiff(DateInterval.Minute, Fields!Check_In_Time.Value, Fields!Date___Time.value)
and tried:
=Max(0,(DateDiff(DateInterval.Minute, Fields!Check_In_Time.Value, Fields!Date___Time.value))) --this one errors and doesn't run
but some results are negative, I want it to return a 0 if it's negative. Can anyone help?
This actually worked for me:
=IIF(DateDiff(DateInterval.Minute, Fields!Check_In_Time.Value, Fields!Date___Time.Value) <= 0, nothing, DateDiff(DateInterval.Minute, Fields!Check_In_Time.Value, Fields!Date___Time.Value))
Unfortunately, there's no function to do this in SSRS.
You'd just need to use an IIF to check for it and use 0 if the Date_Time was before the Check_In_Time.
=IIF(Check_In_Time > Date_Time, 0, DateDiff(DateInterval.Minute, Fields!Check_In_Time.Value, Fields!Date___Time.value))
I've got this expression for my percent column to work out which colour to use based on several column values in my SSRS report.
=IIF(Fields!GrossMarginActual.Value = 0 AND Fields!GrossMarginPercentageActual.Value = 0, 0, Fields!VarianceGrossMargin.Value) AND
IIF(Round(Fields!VarianceGrossMargin.Value,2) < 0.00, "Red", "Black")
However I get the following
The color expression for the text run 'VarianceGrossMarginPercent.Paragraphs[0].TextRuns[0]' contains an error: [BC30205] End of Statement Expected.
I am guessing my syntax on my expression isn't quite right. I've wrapped extra brackets round it but that just gives me back errors. This correct syntax doesn't flag up any errors in the expression box.
Would appreciate a second pair of eyes to look over it.
Try this:
=IIF((Fields!GrossMarginActual.Value = 0 AND Fields!GrossMarginPercentageActual.Value = 0, "Red",
IIF(Round(Fields!VarianceGrossMargin.Value,2) < 0.00, "Red", "Black")))