Math operators parameters - ssrs-2008

I wanted to know if we can use math operators in the parameter of the report.
I have a parameter called "EMP_Attendance".
I want to have the parameter to display and Run the report with values
Parameter:
EMP_Attendance
= 100.00%
<100.00% and >=90.00%
<90.00% and >=80.00%
<80.00%
the Report should run according to this value

This is not natively possible but there is a slight work around.
Create a visible parameter with your four options above.
Create two internal parameters that are populated by two dummy sqls, one lower and one upper.
Make the queries produce the appropriate upper and lower limits based on the users selection, e.g. If 100% is selected lower = 100 and upper = 101.
Filter the dataset by these two limits.

First you would add 4 available values to your parameter with a label of "100%" etc. and values of 1,2,3,4.
Then you have 2 options to filter.
You can add something like this to your query:
SELECT case when EMP_Attendance = 100 then 1
when EMP_Attendance <100 and EMP_Attendance >=90.00% then 2
when EMP_Attendance <90 and EMP_Attendance >=80 then 3
else 4 end as AttendanceGroup
WHERE AttendanceGroup = #AttendanceParameter
The other option is to keep the query as is so that it returns all the data to the report. Right-click on the table and go to its properties. Go to Filters. Add filters here to compare your parameter with the EMP_Attendance value.

Related

Group data based on different size

I am trying to make a report in which I need to show data based on Width groups. Below is an example of data & the required output. I'm unable to make a group which can give this required output. If someone can help please.
The easiest way to accomplish your grouping needs for this data set would be to create a new Formula Field that evaluates the values of the Width data field for each record to determine which group the record belongs within, then do the grouping on this new formula field.
You formula field will look like this.
Select {WIDTH}
Case 400 to 600 :
"G1"
Case 601 to 849:
"G2"
Case 850 to 1049:
"G3"
Default :
"Default text or error message text goes here"
You will likely need to adjust the integer values I'm used in the Case statements to evaluate the WIDTH field. The text that goes into the Default case is up to you. In fact, if it works logically with your needs, you could eliminate the Default case entirely, as it is not required. However, it is good practice to ensure the Switch statement always returns a value, even if that value is text to indicate that something unexpected occurred. This allows your users to easily recognize a bit of a data that may be out of range for the grouping of the report so the report can be modified or the data can be corrected, whichever is the most appropriate action.
The other 3 columns in your required output appear to just be counting the number of records within each group that have a diameter within a range. To get this output you can use Running Total Fields with a Type of summary of Count and then use the range of values in the Evaluate section. The Reset section will be set to On change of group evaluating the group created by the formula field above. You will want to put a sort order on the diameter field though.

Restricting tableau filter options without changing underlying data or display

I am looking for a way to restrict the filter options on a dashboard without changing the underlying data or display.
For example, with a dataset of
Company A: 10 units.
Company B: 5 units.
Company C: 2 units.
I would like the Total Units to display as 17 when no filter is applied, however I would only like to show 'Company A' as an option in the filter.
I can't see your data, so I'm approximating the column names and values. You'll have to adjust these on your end.
Create a parameter, like CompanyFilterParameter, with the values 'Company A' and 'All'.
Create a calculated field to use as your filter, CompanyFilter:
[CompanyFilterParameter] = [Company] OR [CompanyFilterParameter] = 'All'
Put [CompanyFilter] on the Filter card and set it to true. Finally, add your parameter control to the sheet (right click [CompanyFilterParameter] and select "Show Parameter Control").

How to extract just the IN count of a Tableau set

How can I extract the IN count portion of a Tableau set? I can see the IN/OUT counts when I drop the set into Text but can't figure out how to get at the IN value by itself.
Ultimately, I want to create a Pie Chart of three sets with just the IN counts as the measures.
I am using Tableau Public if that is a factor.
You have to be a little careful about specifying what you wish to count.
One way to think of a set is as a Boolean function that gives a value to each data record denoting whether that record is associated with the set.
Another way to think of a set is as a mathematical set whose members are a subset of the values for some discrete field. (Or Tuple of fields)
The difference between the two views is really just a mindset, whether you consider the set as a Boolean function whose domain is a data row in the data source, or whose domain is the field on which the set definition is based.
Say you are looking at Tableau’s Superstore data set where each data record is a line item for a product attached to an order.
If your set is based on the field Region, say its called [My Favorite Regions] and currently contains {“East”, “Central”} do you want your count to be 2 (i.e. the number of regions in the set) ? Or do you want your count to be in the tens of thousands (i.e the number of line items on orders from the regions in the set)? Or something in between, maybe the number of distinct orders (i.e. order ids) within the selected regions...
If you want to count data rows that are associated with the set, you can simply filter by the set and calculate SUM([Number of Records[). If you want to count the regions in the set even though the level of detail of the data is at the order line item level,then you’ll have to use either a COUNTD to count the distinct regions, or some approach to specify what it is you want Tableau to count.
For example, put your set on the filter shelf, and show COUNTD(Region) which could be slow for very large data sets. To get the same effect without an explicit filter, you can define a LOD calculation such as:
{ COUNTD(if [My Favorite Regions] then [Region] end) }
Or you could use a table calc with the SIZE() function to do the calculation in the Tableau client instead of by the data source.
Not sure what your data looks like but you could set a certain condition when creating a set or split the IN/OUT into two different sets.
Here's a link to sets in Tableau.
You can do this with an if statement
IF [set] = TRUE THEN 1 ELSE 0 END
Then I suppose you could sum this calculated field
The most common usage is when you have a lot of categories and want to create an 'Other' category based on the categories that aren't in a set, if the set is a "Top N Set"
To do this:
IF [set] = TRUE THEN [dimension] ELSE 'Others' END

Crystal Reports and Adding values

I am using Crystal Reports XI and I'm trying to add a particular column if one column or another column is set to one.
Here is the current preview:
Username (GROUP 1)
MONTH (GROUP 2)
DATE SUBJECT TOTAL_TIME
End of group 2
End of group 1
Now I want to add the values in total_time if one of the two hidden fields contain 1 (true).
I tried using sum() function but it didn't work as it added all the times together.
I'm still new to Crystal Reports and I tried searching on google but nothing came up similar to what I need.
Any help would be greatly appreciated.
One alternative that I can suggest, You can use Parameter fields on your report.
Do the calculation on Code behind and set the calculated sum to parameter field on Page_Load event of Crystal Report page.
This parameter field will be used to display the sum on report page.
Please check this link to see
-How to create Parameter Fields:
http://devlibrary.businessobjects.com/BusinessObjectsXIR2/en/en/CrystalReports_dotNET_SDK/crsdk_net_doc/doc/crsdk_net_doc/html/crtsktutorialscrvparametersdiscretecreatingreport.htm
-How to set values in Parameter Fields:
http://msdn.microsoft.com/en-us/library/aa289936(v=vs.71).aspx
Your best option will be use "Running totals" by this way you can control the flow by keeping a condition to sum when the required column is 1.
Did you think about small trick? You wrote: I want to add the values in totaltime if one of the two hidden fields contain 1 (true).
Under these circumstances you can calculate helper field Total_Time_Conditional using formula:
Total_Time_Conditional = IIf(HiddenField1 = 1 or HiddenField2 = 1, 1, 0) * Total_Time.
This will multiply Total_Time
by 1, if any of hidden fields is 1
by 0, if both hidden fields are 0
Calculating Sum(Total_Time_Conditional) will give you expected result.

SSRS - Expression using different dataset fields

I have a report with multiple data-sets. Different fields from different data-sets are used in different locations of the report.
In one part of the report, I need to do a calculation using fields from two different data-sets. Is this possible within an expression?
Can I somehow reference the data-set the field is in, in the expression?
For example, I'd like to do something like this:
=Fields.Dataset1.Field / Fields.Dataset2.Field
You can achieve that by specifying the scope of you fields like this:
=First(Fields!fieldName_A.Value, "Dataset1") / First(Fields!fieldName_B.Value, "Dataset2")
Assuming A is 10 and B is 2 and they are of type numeric then you will have the result of 5 when the report renders.
When you are in the expression builder you can choose the Category: Datasets, your desired dataset highlighted under Item: and then double click the desired field under Value: and it will appear in your expression string with the scope added.
Using same logic you can concatenate two fields like so:
=First(Fields!fieldName_A.Value, "Dataset1") & “ “ & First(Fields!fieldName_B.Value, "Dataset2")
As PerPlexSystem writes, asuming you only want to compare the first value from a dataset with values from another dataset, you can use the First function.
However, if you want to compare the values of each row from one dataset with with the values from each row of another dataset, then you will need to use a subreport - see here for further details.
Another option is to use a parameter as a variable. This is helpful if you want to create a calculated field in one of the datasets. This is best applied when the parameter value comes from a dataset with a single record.