Additional nested IIF - reporting-services

I'm really hoping someone can help with this, I'm not really hot on the finer points of SSRS and I'm struggling to find any articles that answer my query, or at least point me in the right direction.
I am trying to write an report that looks at the grades a student gets for each unit they take, change this from a "D" or "M' etc... to a value; 1 or 2 etc... and then gives me the average based upon the number of units they completed.
I've managed to get this far, but I now need to output a field that shows if the average value is between 1.0 and 1.5 display "Pass", between 1.6 and 2.5 display "Merit" and between 2.6 and 3.0 display "Distinction".
This is where I've got thus far:
=SUM(IIF(Fields!ActualGrade.Value="D",3,IIF(Fields!ActualGrade.Value="M",2,IIF(Fields!ActualGrade.Value="P",1,0))))/Fields!CompletedUnits.Value
I think I may need another IIF in front of the SUM, but I'm really not too sure.
Any help would be massively appreciated
Thanks
S

Try using this expression:
=Switch(
(SUM(IIF(Fields!ActualGrade.Value="D",3,IIF(Fields!ActualGrade.Value="M",2,IIF(Fields!ActualGrade.Value="P",1,0)))) /
Fields!CompletedUnits.Value) > 2.6, "Distinction",
(SUM(IIF(Fields!ActualGrade.Value="D",3,IIF(Fields!ActualGrade.Value="M",2,IIF(Fields!ActualGrade.Value="P",1,0)))) /
Fields!CompletedUnits.Value) > 1.5, "Merit",
(SUM(IIF(Fields!ActualGrade.Value="D",3,IIF(Fields!ActualGrade.Value="M",2,IIF(Fields!ActualGrade.Value="P",1,0)))) /
Fields!CompletedUnits.Value) > 0.9, "Pass",
true,"Nothing"
)
Also if you want to show the average in a column and the determined string (Metir, Pass, and Distinction) you can reference the text value by doing someting like this:
=Switch(
ReportItems!TextBox14.Value > 2.6, "Distinction",
ReportItems!TextBox14.Value > 1.5, "Merit",
ReportItems!TextBox14.Value > 0.9, "Pass",
true,"Nothing"
)
Where TextBox14 is the textbox where you put the Sum(IIF(...))/YouField expression.
Hope this helps.

Related

What is the best way to model an environment to force an agent to select `x out of n` choices?

I have an RL problem where I want the agent to make a selection of x out of an array of size n.
I.e. if I have [0, 1, 2, 3, 4, 5] then n = 6 and if x = 3 a valid action could be
[2, 3, 5].
Right now what I tried is have n scores:
Output n continuous numbers, and select the x highest ones. This works quite ok.
And I tried iteratively replacing duplicates out of a Multi Discrete action. Where we have x values that can be anything from 0 to n-1.
Is there some other optimal action space I am missing that would force the agent to make unique choices?
Many thanks for your valuable insights and tips in advance! I am happy to try all!
Since reinforcement learning mostly about interacting with environment, you can approach like this:
Your agent starts choosing actions. After choosing the first action, you can either update the possible choices it has by removing the last choice (with temporary action list) or you can update the values of the chosen action (giving it either negative reward or punishing it). I think this could solve your problem.

decimal lag values in ACF plot instead of integers lags

I have a monthly time series. When I run the code acf(timeseries), the lags on the x axis show up as decimals instead of integers, as shown in the screenshot:
What is wrong? How could I have lags=c(1,2,3,4,5,6,etc) on the x-axis? I need something like this (photoshopped photo) (excuse the mis-alignment of values with ticks on the x-axis):
Try Acf (first letter is in upper-case) function in package "forecast".
Perhaps it's because you are using a non-desirable format for the acf/ccf function.
I faced the same problem and I solved it by changing the input vectors from time-series (ts) to numeric:
[variable]<-as.numeric([variable])
And it worked. I hope it helped.
Since you are using a tseries object, you need to pass coredata() to the ACF and PACF functions:
acf(coredata(your_ts_object))
pacf(coredata(your_ts_object))
This will pass just the numerical values in the time series and won't make a mess, giving you integer lags.
I think you have to get the results from the acf() function then plot it in your own like this:
storing acf results:
a=acf(ts,plot = F) #ts is an annual time series(frequency =12)
plotting acf:
plot(a$lag*12,a$acf,xlab="Lag",ylab="ACF",main="",type="h")
note that you have to multiple the lag * frequency of your serie in this case 12.
plotting horizontal lines:
abline(h=c(-0.19,0,0.19),col=c("blue","black","blue"),lty=c(2,1,2))
h : to specify where to plot ths lines
col : for the colors of the lines
lty : to specify the type of the line
that worked for me, i hope that's what you locking for
As the ts is monthly, so the yearly lag is divided into 12. The first figure is just a portion of the total ACF (i.e., for 1.5 years approx.). To have ACF for the full ts, use acf(ts_object, lag.max = the max length of your ts_object). E.g., if you have 15 years monthly data, then set lag.max = 12*15.

SSRS 2012 Custom Code/Expression for Divide by Zero and calculations

I know similar questions have been asked. However, I have not found anything that exactly helps me out in my situation.
I need to avoid divide by zero but before I do a divide with another column value, I am performing a math calculation:
=Sum((Fields!col1.Value) - Sum(Fields!col2.Value) / Sum(Fields!col2.Value))
I basically want to do a subtraction first, then a divide but I am unable to get the expression or the custom code to work for me. And before I spend too many hours on this one, I figured I would reach out for help.
This is the code I have come up with so far and it works, but I want the column to show nothing instead of 0:
=IIf(Sum(Fields!LWCasesBudget.Value) = 0, 0,
Sum(Fields!LWShipQuantity.Value) - Sum(Fields!LWCasesBudget.Value))/
IIf(Sum(Fields!LWCasesBudget.Value) = 0, 1, Sum(Fields!LWCasesBudget.Value))
It seems like you are happy with your calculation. If the 0 is the only issue then try and replace the 0 with the word "nothing".
Example:
=IIf(Sum(Fields!LWCasesBudget.Value) = 0, nothing,
Sum(Fields!LWShipQuantity.Value) - Sum(Fields!LWCasesBudget.Value))/
IIf(Sum(Fields!LWCasesBudget.Value) = 0, 1, Sum(Fields!LWCasesBudget.Value))
Hope that helps.

SSRS Format to display as percent

I've gone through quite a few examples on here and I apologize if I'm asking a repeat question, as far as I can tell, I am not.
I have an SSRS report made that shows gross sales for certain aspects of our sales departments. They are broken down, in row, by "cost, gross profit, gross profit %, order count, total sales." The columns are the aspects of our sales. Web sales, phone sales, etc....
In the tablix I can format a text box to display the results as numbers, but as you can see, I have also Percentage and Count in there. I don't know how to format those within the context of the original text box format. So I know I have everything that shows under there as a number already, but how do I handle getting the percentage to show as a percentage and the count to show as a count?
For example, all the percentages currently show as, "$0.35" and various other numbers that follow that form. The count's currently appear as currency too.
I've used an example I found on here, "=Iif ( Me.Value = Floor ( Me.Value ) , "0%" , "0.00%" )," but all that did was make everything that showed up in that column, "0.00%" I am fairly new to SSRS and have been cramming consistently for the past two weeks, but I just cannot find help on this. Thank you in advance for anything you can offer.
Update: =IIF(Fields!LVS_Web.Value=0.00, "0%", format(Fields!LVS_Web.Value, "P"))
That worked... to a degree, but now everything is a percent.... thinking ELSE here but I don't know how ELSE goes in, I've not once seen the word ELSE.
Update 2: The thing that I've noticed is that in the statement, where it says, "=0.00, "0%"," that doesn't even really apply. I've just put that there because I'm new to this and I just needed an argument involved. I took the 0% and changed it to N under the condition that the number was < .99, hopeing I would just catch all of the decimals that fell below the value of 1. Like, "$.23", which later became 23.45%, so I COULD do that, but what I don't udnerstand is it made everything else, "N," instead of a number. Why is that? It doesn't make everything else, "P?"
I'm losing my damned mind.
There is also the fact that this is information being pulled from a stored procedure, I don't really know too much about those quite yet, I get assigned simple tasks ever so often as a stepping stool for learning. I don't really know what the query was, but I couldn't edit it if I wanted to. This can be done with expression formatting but my expression is too broad, but I get mixed results using Greater or Less than, and it's probably not the wisest thing to use since these numbers are not set in stone. My day is almost done, I've made very very little progress, but I had a good lunch. So success.
So I provided my own answer for this problem, and it works. Thanks me. Thanks to all the tried to help me and did help as well. I appreciate the effort strangers will put out for each other.
I've had a new problem develop, I need to display a time relative to the data being pulled. I can put NOW in there and get today's date, but if someone is pulling information from FEB, they may be a little off-put by the current date. I'll probably get this figured out soon, but if anyone can help in the meantime, I would appreciate it.
A standard principle is to separate data from display, so use the Value property to store the data in its native data type and use the Format property to display it how you want. So rather than use an expression formatting the Value property such as =Format(Fields.SomeField.Value, "0.00%") leave the Value as =Fields!SomeField.Value and set the Format property to P2.
This is especially important when exporting your report to Excel because if you have the right data type for your data it will export to Excel as the right data type. If you use the Format function it will export as text, making sorting and formula not work properly.
The easiest thing to do to control the formatting is use the standard numeric formats. Click on the cell or range of cells that you want to have a certain format and set the Format property. They are a format specifier letter followed by an optional digit for precision (number of decimal places). Some useful ones are:
C Currency with 2 decimal places (by default)
N4 Number with 4 decimal places
P0 Percentage with no decimal places
Click on the link above for the full list. Format the number cells as numbers and the percents as percents - you don't need to try to make one format string fit every cell.
These standard numeric formats also respect regional settings. You should set your report's Language property to =User!Language to use the user's regional settings rather than the report server's.
If the number is already * 100 eg. 9.5 should be shown as 9.5% then use the format:
0.00\%
9.5 -> 9.5%
0.34 -> 0.34%
This way you can use the standard number formatting and just add the % to the end. The \ escapes the %, preventing the *100 in formatting (which would make 9.5 show 950%.).
=iif(Fields!Metric.Value = "Gross Profit %",
Format(Fields!LVS_Web.Value,"P"),
iif(Fields!Metric.Value = "Order Count",
Format(Fields!LVS_Web.Value,"G4"),
Format(Fields!LVS_Web.Value,"C")))
This is what saved me and did what I wanted. There is another error, but it's my bosses fault, so now I get to laugh at him. Thanks everyone.
Source:
https://technet.microsoft.com/en-us/library/bb630415(v=sql.100).aspx
This is simple to use,
Percent of (the sum of line item totals for the current scope)/(the sum of line item totals for the dataset).
This value is formatted using FormatPercent specifying one decimal place.
="Percentage contributing to all sales: " & FormatPercent(Sum(Field!LineTotal.Value)/Sum(Field!LineTotal.Value,"Sales"),1)

How can I always round up decimal values to the nearest integer value?

On a report I have the following code for a field:
=Sum([PartQty]*[ModuleQty])
Example results are 2.1 and 2.6. What I need is for these value to round up to the value of 3. How can I change my field code to always round up the results of my current expression?
This is an old Access trick I learned a very long time ago, and it makes use of the way Access handles fractional, negative numbers. Try this:
-Int(-[DecimalValue])
It's odd, but it will always round your numbers up to the nearest whole number.
you could do
=Int(Sum([PartQty]*[ModuleQty]))+1
I think. That would get the Int part of the sum (2) and then add 1. you might need to be a little more clever as this will probably give you 3 even if the sum is exactly 2, which is probably not what you want.
not tested it but something along these lines might work (access syntax is not that great, but should give you the right idea) :
Iif(Sum([PartQty]*[ModuleQty])-Int(Sum([PartQty]*[ModuleQty]))=0,
Sum([PartQty]*[ModuleQty]),
Int(Sum([PartQty]*[ModuleQty]))+1)
Test this:
Round(yournumber + 0.5, 0)