Filtering name with two condition - google-apps-script

I have a sample list of student and grades/subject in this file
enter image description here
https://docs.google.com/spreadsheets/d/1NeHlUaRnbvdJ2yJ38fUETGgBoYseQ8CuXmwRCwObAlM/edit#gid=0
On the range A16:A I'd like to see the list of names who has the grades of around 90-100 when I check any of the checkbox on B15:k15
the first example is when I check all of the boxes
I will only see the first name on the list because he is the only one with the 90-100 scores on all subject
2nd example when I check B15 and C15
I will only see the 1st and 2nd names on the list because he's those who only able to get a 90-100 score on those two subjects.
Is there a way to do this kind of filtering? thank you so much

Since this is your first post, I'm going to go with the approach I think you'll find easiest to understand. It's a long formula (which I've placed in a new sheet called "Erik Help" in A16), but it's just a repeat of the same element several times:
=FILTER(A2:K11, IF(B15=TRUE, B2:B11>=90, B2:B11^0), IF(C15=TRUE, C2:C11>=90, B2:B11^0), IF(D15=TRUE, D2:D11>=90, D2:D11^0), IF(E15=TRUE, E2:E11>=90, E2:E11^0), IF(F15=TRUE, F2:F11>=90, F2:F11^0), IF(G15=TRUE, G2:G11>=90, G2:G11^0), IF(H15=TRUE, H2:H11>=90, H2:H11^0), IF(I15=TRUE, I2:I11>=90, I2:I11^0), IF(J15=TRUE, J2:J11>=90, J2:J11^0), IF(K15=TRUE, K2:K11>=90, K2:K11^0))
The first argument of FILTER tells the function what to filter (in this case A2:K11).
After that, an IF statement is set up to check each checkbox. If the checkbox is checked, the FILTER will only include students who obtained a 90 or higher in that subject.
If the checkbox is NOT checked, then the student is automatically included (that's the part that says "B2:B11^0" etc., since anything to the zero-power equals 1, and 1 and TRUE are the same to Google Sheets). In other words, if no checkboxes were checked, then all students would read TRUE for all subjects, i.e., all students would be included (or, to think of it another way, no one is rules out). While the ^0 is not strictly necessary (i.e., any number other than zero is the same as TRUE), I think it's better formula practice and easier for others to understand if TRUE is represented either as TRUE or as 1.
I also set conditional formatting on A15:A, to bold the name as you had it. (The conditional formatting rule says, in English, "If anything is there, use bold.") You can see the rule by clicking anywhere in the range A15:A, then selecting Format > Conditional formatting from the menu and clicking the open the rule that appears in the window to the right of the screen.

Related

What does the "ved" parameter in a google search refer to?

I've spent like two hours or more trying to figure out what a "ved" parameter on a Google search means. A curious person I am.
My finds so far:
$ved value changes-
1 - every different search result (diff keywords)
2 - every different resulted block (the url blocks/boxed on the resulted google search, but they are quite similar, as I'll write down below)
3 - every different geolocation perhaps
Consider these tests or lookups:
1-
Diff keywords, but first block/position in list:
&ved=2ahUKEwidsaSd4M_1AhVlk_0HHUxOCQYQFnoECAsQAg
&ved=2ahUKEwj2pZyN5s_1AhVRmuYKHZ5IB5EQFnoECAcQAg
I thought the "ved" value refers to the block/position of a url in the result list, but no.
2-
Twree different urls, first and second from the 1st and 2nd blocks of first page, then third from a "much farther on the list" block:
ved=2ahUKEwjq1-Wb1s_1AhW6SWwGHZwpBMwQFnoECD8QAQ
ved=2ahUKEwjq1-Wb1s_1AhW6SWwGHZwpBMwQFnoECCAQAQ
ved=2ahUKEwiZ2NDe1s_1AhVaTmwGHThIA5U4PBAWegQIGRAB
The same website url, from different countries (not considering blocks or position in list):
&ved=2ahUKEwiopK2X08_1AhUgxzgGHQEbDkcQFnoECBIQAQ
&ved=2ahUKEwjpueqC1M_1AhWJq3IEHYEDAfc4FBAWegQIDBAB
&ved=2ahUKEwih09Wz08_1AhUY7WEKHQYdBB8QFnoECEIQAQ
Very similar they are.
I'd really love to know what they mean. Any ideas are appreciated too!
I found an interesting article explaining the subject : https://moz.com/blog/inside-googles-ved-parameter
TL;DR:
A ved code contains up to five separate parameters, which each tell you something about the link that was clicked on:
1st (parameter1: Link index) gives you an idea of where the link was on the page.
2nd (parameter2: Link type) is a number that corresponds to the 'type' of the link that was clicked.
3rd (parameter7: Start result position) is the cumulative result position of the first result on the page.
4th (parameter 6: Result position) indicates the position of your page in the search results.
5th (parameter 5: Sub-result position) like the (parameter 6), except it tells you the position in a list of sub-results, such as breadcrumbs, or one-page sitelinks.

How to select from a selection box with a variable in the name?

I am having trouble using selecting from this select element.
<select name="vehicle_attrs[position_count]" class="mb1"><option>Position / Quantity</option><option>Front</option><option>Rear</option></select>
I have tried
select('Front', :from=>'mb1')
select('Front', :from=>'vehicle_attrs[position_count]')
select('Front', :from=>'vehicle_attrs[1]')
All of them result in a can not find selection box error
I've never liked how restrictive Capybara's concept of a 'locator' is (i.e. must have a name/id/label), but if you dig into the source code, those helpful methods like select, click_on, and fill_in are just wrappers for find and some native method of Element, which takes arbitrary CSS, and works in almost all situations. In this case, you could use:
find('[name="vehicle_attrs[position_count]"]').find('option', text: 'Front').select_option
Since dropdowns often have multiple similar options, where one is a substring of the other, you might consider using an exact string match, like
find('[name="vehicle_attrs[position_count]"]').find('option', text: /\AFront\z/).select_option
From the docs for select - https://www.rubydoc.info/github/teamcapybara/capybara/Capybara/Node/Actions#select-instance_method - we can see that the from option takes "The id, Capybara.test_id atrtribute, name or label of the select box".
Neither 'mb1' or 'vehicle_attrs[1]' are any of those so they would be expected to fail.
'vehicle_attrs[position_count]' is the name so assuming the box is actually visible on the page (not replaced with a JS driven select widget, etc), that should work. If it doesn't, then edit your question and add the full exact error message you get when trying to use it. Of course if there is only one select box on the page with an option of 'Front' then you don't need to specify the from option at all and can just do
select 'Front'

Only allowing one Drilldown in SSRS

It took me hours of searching and putting together piecemeal parts to find the solution to this, so I figured I'd post it on here in the hopes of helping someone else.
The Problem: We need to display a report, with proper grouping and drilldowns. However, we should only allow one group to be drilled down at one time.
SSRS doesn't exactly have robust scripting options - for instance, you can't close other groups "on click" or anything like that. So how do you do it?
In My example i'm using the AdventureworksDW database. I want to have a dataset that includes the total sales for each group and region. My Stored Procedure looks something like this:
SELECT dst.SalesTerritoryGroup,
dst.SalesTerritoryRegion,
SUM(fis.SalesAmount) AS SaleTotal,
DATEPART(YEAR,fis.OrderDate) AS OrderYear
FROM [dbo].FactInternetSales AS fis
INNER JOIN [dbo].DimSalesTerritory AS dst
ON fis.SalesTerritoryKey = dst.SalesTerritoryKey
WHERE fis.OrderDate < #QueryEndDate
GROUP BY
dst.SalesTerritoryGroup,
dst.SalesTerritoryRegion,
DATEPART(YEAR,fis.OrderDate)
UNION ALL /*The ResellerSales table. Same info.*/
From there I added a table with two groups: SalesTerritoryRegion and its parent, SalesTerritoryGroup. I also added a column to the left INSIDE the SalesTerritoryGroup, with an X (this can also be an image if you'd like). This is the "Drilldown" button that we'll use.
Create a string parameter, mine was #ExpandedGroup. Set the Default to an empty string (so that all the groups start out collapsed). Right click on the SalesTerritoryRegion group, or whatever your subgroup is, and go to the visibility tab. Click "Show or Hide based on Expression" and enter something like this:
=iif(Parameters!ExpandedGroup.Value="" or
Fields!SalesTerritoryGroup.Value<>Parameters!ExpandedGroup.Value,True,False)
This statement means: If we haven't opened a dropdown, or if the dropdown isn't the one selected, set hidden to true. Otherwise, false.
Next click on your "X" column to the left of SalesTerritoryGroup or your supergroup. Right click to go to Textbox Properties. Click the action tab. From there select "Go to Report". When you specify a report, make the target itself (For instance, mine is Main). Then, add parameters to the report.
The most important here is ExpandedGroup. The name should be ExpandedGroup, but the value is not just [ExpandedGroup]. Instead, it's an expression:
=IIF(Fields!SalesTerritoryGroup.Value=Parameters!ExpandedGroup.Value,
"",
Fields!SalesTerritoryGroup.Value)
This expression says: If the Group is the same as the Expanded group, make ExpandedGroup an empty string when you load the report. Otherwise, send the TerritoryGroup value. Essentially, this will let us toggle on and off the drilldown (same as you would in the report if you had traditional drilldowns).
Note: Also be sure to pass other parameters! For instance, my query requires a date to exclude some transaction data. If you don't pass this parameter in the "Go to Report" action, then you'll have to enter it again when you DrillDown. This also means you can give yourself even more flexibility when you click a drilldown (changing a chart that's displayed etc.) which is what I'm doing for this project.
Hope it helps someone out! Of course, if there is a more elegant or simpler solution I'd absolutely love to hear it.

How to get the max of a sum?

Can anyone tell me how do I get the Max of a calculated field? Below is an image of my situation:
Note that Flag is of type int.
I want to write the expression in the image , but when I use it, it kinda does:
Sum(Sum(Fields!Flag.value))
Can anyone help me out on this. I think I need to add scope for the Sum(Flag) but when I add the group scope as EMPID as:
=iif(SUM(Fields!Flag.value,"Fields!EmpID.Value")>2,"RED",nothing)
It throws me an error saying something about the scope.
EDIT:
I need attendance of each employees. FLAG is basically 1 if absent and 0 if anything else.
The bottom row(Flag,Date,Status,Comment). Now I have an alert There:
=iif(Fields!Flag.Value=1,"RED",Nothing)
Beside the Textbox(Textbox62) in middle row(EmpID,EmpName) I did Expression:SUM(Flag) and in the Fill section in Text Box Properties i have done:
=iif(SUM(Fields!Flag.value,"Fields!EmpID.Value")>2,"RED",nothing)
So the above expression creates an alert if employee is absent more than 3 days.
The top most row(Department,Manager) can be drilled down for to see more detailed view of the report. Now my problem is, in the column (FLAG) i need to create a Background color change if any employee in a particular department is absent more than 3 days.so that we do not have to drill down all the departments in order see if any employee is absent or not.
So my approach was to see the Max(Sum(Flag))>2 then create color change. I tried:
=iif(MAX(Sum(Fields!Flag.Value))>2,"Red",Nothing)
It does not work at the Department level as it basically considers (SUM(Sum(Flag))).
Thanks................
If you don't specify the scope of an aggregate, it is assumed that you are using the current scope. For example, when you say
Sum(Fields!Flag.value)
It is interpreted as something like
Sum(Fields!Flag.value, "EmpID")
The scope is the name of the Group, not the name of a dataset field.
Depending on where it is in the table. When you want to say something like
Sum(Sum(Fields!Flag.value))
You need to specify the scope for each one that isn't going to be the current default.
In your case you should use something like this:
=iif(MAX(SUM(Fields!Flag.value, "EmpID"), "Department")>2,"RED",nothing)
Again, pay attention to which group each aggregate is referring to and where the expression is on the table.
Also, this expression in a textbox will just make the word "RED" appear in the box. If you want it to change the color, you have to put it in the "Fill color" expression in the properties.

SSRS- charts colour coding

I have SSRS solution for SQL 2005 and 2008.
I am showing output in the form of chart- column chart with each column representing different database.
Is there a way to display each column in different color?
Regards
Manjot
You can use a formula to set the colour of each column, but that would work best if you knew what the individual series values ('databases'?) were going to be.
Right-click on your chart and bring up its properties. Now switch to the Data tab and select the first item in the Values list. Click the Edit... button to show the properties for the values (the columns) in your chart. Over on the Appearance tab there's a Series Style... button which takes you to another dialog.
On this new Style Properties dialog, switch to the Fill tab. That's where you set the colour for each of your columns. This can be a formula, so you might make it something like:
=Switch(
Fields!Database.Value = "master", "Blue",
Fields!Database.Value = "msdb", "Red",
"Green")
If you don't know in advance which 'databases' are going to be represented on the chart, this method won't work very well. In that case you might be able to come up with a formula which hashes the database name and comes up with a colour to match. That sounds like an interesting challenge, so add to your question if you need help doing something like that.
Edit
I just got a hash-based-colour-scheme working. It's a pretty nasty piece of code, but it did manage to get me a unique colour for every (string valued) column. Perhaps someone can come up with a better algorithm and post it here. Here's mine:
="#" & left(Hex(Fields!Database.GetHashCode()), 6)
So that's getting the HashCode for the string (a numeric value) and converting it to hex, then taking the leftmost six characters and prepending it with a "#" sign. That gives us a string that looks like a colour value (eg #AB12F0).