Input the Employee no and the Basic Salary of the Employees in an organization ending with the dummy value -999 for Employee no and count the number Employees whose Basic Salary >=5000.
As used here, a dummy value is different than a regular value, and used to select an organization. It may signify test data.
In production software, you don't want to assign meaning to a partial value of a field. As this implies that any changes to the value of a field may break your software unexpectedly. Instead create a new dedicated field (boolean is_test_data).
Related
I have a report, that shows the individual sales commission for each employee.
The expression for the Sales Commission is:
=Sum(Fields!Total_Comission.Value)*Parameters!Distribution_Factor.Value*Fields!Individual_Factor.Value
Now I want to add a total for this field. If I just right click the cell and click on Add Total, it works but gives out the wrong total.
If I try to sum the field like this:
=Sum(Reportitems!GO_Prov.Value)
I get the error:
The Value expression for the textrun 'Textbox93.Paragraphs[0].TextRuns[0]' uses an aggregate function on a report item. Aggregate functions can be used only on report items contained in page headers and footers.
Is there a workaround to sum the aggregated field of this tablix? Maybe with a code?
Thanks in advance.
Update1:
Unfortunately i don't know how to write custom codes. But I found this code:
Public Total_lookup_Sum As Integer = 0
Public Function Lookup_Sum(ByVal value As Integer) As Integer
Total_lookup_Sum = Total_lookup_Sum + value
Return value
End Function
The expression i used for the Sales Commission is now:
=Code.Lookup_Sum((Sum(Fields!Total_Comission.Value)*Parameters!Distribution_Factor.Value*Fields!Individual_Factor.Value))
And the expression for the field where i would like to get the sum is:
=Code.Total_lookup_Sum
Now i get the error:
There is an error on line 0 of custom code: [BC30205] End of
statement expected.
Is there a way to solve this?
Scenarios like these can be tricky in SSRS. From your description (even though the screenshot doesn't really show everything), I'm guessing that you've got rows grouped by salesperson. In your column that's calculating the commission, you've got a sum of "Total_commission", but you've just got the "Individual_Factor" value not aggregated. Again, having a guess, but each underlying row (by employee) must have the same "Individual_Factor" value (so actually using Min(Individual_Factor) would give the same result).
But then, when you try and just take the same formula (or even a derivation of the formula), and make an overall aggregate of all of the rows, how does SSRS know which "Individual_Factor" value to use? You don't want Min() or Max(), because that would just be the lowest or highest value across all of the salespeople.
Your suggestion of a workaround via code is generally the way that I approach this. You need a report variable, something like "Commission_Grand_Total", and then you need a function in the report code that accepts 1 parameter, and in the function you'll add the parameter value to the variable. The easiest thing to do is to make the parameter the return value of the function.
Then, in the field where you currently have your commission formula (on the salesperson row), the expression in that field becomes =TheFunctionYouCreate((Sum(Fields!Total_Comission.Value)*Parameters!Distribution_Factor.Value*Fields!Individual_Factor.Value))
By passing the formula to the function, you're achieving two things:
The function will take each salesperson's calculated commission and add it to your report variable
The function will output the parameter value that you passed in (since you want to display the calculated commission amount on each salesperson's row)
Lastly, to display the overall total, the expression for that field is just the report variable that holds the overall total (that has been cumulatively added to as SSRS wrote out each salesperson's record)
TIP: I sometimes do this same sort of thing, but if I don't want the row-by-row value to be shown (I just want the cumulative total to be calculated), just put the expression that calls the function in a hidden column. SSRS will still run the function as it renders each row, but obviously it's just not displaying the result of the function.
Some MS reference for report variables and code
https://learn.microsoft.com/en-us/sql/reporting-services/report-design/built-in-collections-report-and-group-variables-references-report-builder?view=sql-server-ver15
https://learn.microsoft.com/en-us/sql/reporting-services/report-design/add-code-to-a-report-ssrs?view=sql-server-ver15
This is untested unfortunately but...
assuming you have a rowgroup for employee called EmployeeGroup then the expression would look like this...
=SUM(
Sum(Fields!Total_Comission.Value, "EmployeeGroup")
* Parameters!Distribution_Factor.Value
* FIRST(Fields!Individual_Factor.Value, "EmployeeGroup")
)
The inner expression reads as
Sum of Total_Comission with current employee group
... multiplied by Distribution Factor
... multiplied by the first individual factor with the current employee group
The outer expression just sums all the individual employee level sums.
Is it possible to have this? Assuming there are many attributes in the relations A and B
First we must remember that a derived attribute is a changing attribute that can be achieved by another, such as your age (current date - date of birth)
Yes, imagine this situation, you have the relationship of many to many students - course
We can say that a student will take a course that will start on January 3rd and last 8 weeks of effective classes, we can't put directly the attribute "end date" because this date could change (for example because of a strike, a pandemic) but we can put the start date and make the calculation.
This is related to MS Access 2016. I have a field called Name in which I have a long string. Every record in the Name field has an year mentioned in it along with some string. The year is always mentioned in paranthesis for example.
The story of a dead girl (1987) by Jack Ding
3 days of necro (2007) on water
etc...
I want to create another field called year in which I just want to add the year of that record automatically. I also want to delete everything after and including the year information in the Name field from every record. so in the above example I want to delete the string '(1987) by Jack Ding' and '(2007) on water' from the respective records.
I know I can just type it or Copy/Paste info from Name to Year but I have 4000+ records and I want to build a Query or Expression or Macro or whatever (I seriously don't know what) that will take only the year Info from Name field and put it in Year field automatically and delete everything after the year that is mentioned in the Name field (including the year itself)
Any Help will be appericiated
THANKS
You can use this in sql or vba, but this expression should output the correct value assuming there is only one open parentheses in any single string (though there are workarounds if there are multiple):
MID([Name],InStr(1,[Name],"(")+1,4)
The InStr function searches [Name] for the first open parentheses and returns the position of that character in the string. Mid extracts a specified number of characters from a string, but you have to tell it where in the string to start. Nesting them together, InStr tells Mid to start extracting at the position of the first open paren, +1 character, which should be the first digit of the year. Then Mid takes the 4 digits from that starting point and returns the string.
If your year field is a date data type, you may improve the expression by wrapping it in CDate which converts a string to a date data type.
You can write an UPDATE query using this expression to add the year for each record into the year field in the table:
UPDATE MyTableWithName&Year
SET Year = CDate(MID([Name],InStr(1,[Name],"(")+1,4));
EDIT: I missed the delete portion of your question. As you can see, InStr can be used to identify the position of your first open parens, so it can be used the same way with the LEFT function to truncate everything but the title. So the expression would be something like:
LEFT([Name],InStr(1,[Name],"(")-1)
You can then use that in a second UPDATE query (I would do these consecutively, since we don't want to truncate before the year is extracted) SQL code would be:
UPDATE MyTableWithName&Year
SET Name = LEFT([Name],InStr(1,[Name],"(")-1);
I am trying to loop through Column Values inside my Table.
I have a register form, which provides the user with UNIQUE ID, based uppon his information.
For example:
Country = Austria
Each user that selects country Austria will get some sort of Unique Value for that match (lets say 00).
Account ID look like this:
XXXX00UNIQUECODE
Each country has it´s own unique value: (AT = 00, DE = 01, etc)
Now, I want to generate a UNIQUE CODE for each user, that will be just an increment (+1) value of the previous UC value stored in the table, for the same country!
In order to do that, I need to somehow loop through the Column, where the Account IDs are stored and search for the match.
The thing is, when a user tries to generate the UNIQUE CODE, he does not have it yet, so he has only:
XXXX00
Now I need to find all the XXXX00 strings in my AccountID Column, and store them in an Array - then find the Max Value of those and increment it.
BUT I dont know how to search for a part of the string inside a Column of the Table ?
Just the XXXX00 part, not the entire Account ID XXXX00UNIQUECODE.
Agh, I hope you can understand me. It´s quite complicated I know, but I´m really stuck here. Hopefully, someone will know what I mean and maybe even find a smoother solutions for this.
Thanks in advance!
You're pounding a square peg into a round hole. Why not just create a new column called UserID and then you can do:
SELECT Max(UserID) FROM MyTable WHERE Mid(AccountID, 5, 2) = "00"
and increment it by 1.
Better yet, store CountryCode, UserID and the XXXX part in separate fields, and index them. It'll save time when you search or filter, which I'm assume you're going to be doing.
I have an excel file that lists multiple students and courses they've taken and when they were taken. The worksheet is set up so that the students are listed in rows and the courses are in columns along with the dates. I created a calendar on a separate worksheet to show a snapshot view of the students and their courses taken. I am struggling with how to feed the data into the Calendar. Basically, the logic is that I need to search through (or loop through) an array of non-adjacent cells named StatusArray and if there is a value present then I need it to return the student ID and the associated Course name. The kicker is that there are sometimes multiple courses per student so I need to make sure it returns all of them, each on a new line. And the status columns all have formulas in them because they are generated based on the dates entered.
Example:
Worksheet 1 columns - Student ID, name, address, course status, start date, end date, grade, course status, start date, end date, grade, ......
I need it to read through the course status columns and (when not blank) return the status header for the status column in J and the student ID in column C of the Calendar worksheet. Bonus if it returns Name, Address, Phone, and comments as well!
I am completely stuck as to how to do this!
A brute-force approach: Let's assume you have 4 repeating blocks of "status/start/end/grade" information. I understand 4 course blocks is the most any student has, but some students have data populated in three or fewer blocks.
First, copy only the region of data that has student ID, name & address. Paste it immediately below the existing list of students. Repeat until you have a total of 4 sets of student information. The first set is your original, then 3 redundant copies below.
Next, cut the right-most (4th) block of status/etc. information, and paste it next to the 1st repeated section of students. Make sure you align the pasted status column with the first block's status column. Repeat this exercise two more times, cutting out the rightmost block of status etc. and pasting next to the next section of redundant student information.
You should now have a table with only 7 columns of data: the first three are student ID, name & address, same as before. The next four columns are course status, start, end & grade. Now, you should be able to simply filter the "status" column for what you're looking for.
P.s. I don't usually recommend brute-force, but in this case it's impossible to code something more elegant without a lot more specifics about your layout. This solution should be quick and easy assuming you don't have a ton of data to manipulate and assuming you don't need to do this very often.