SharePoint 2013 Calculating Scores - if-statement

I am working in SharePoint 2013. I am trying evaluate the work of my staff and will be using a list to track this and want to assign a grade to the results. If the person gets a 4 out of 5 I want them to receive 80%.
The way I'm doing this is with a list that contains 5 questions with a drop down menu and the response are Yes, No, N/A. There is a second 5 columns that converts the drop down list selection to a 1, 0, or "Empty Record". Yes=1, No=0, N/A=Empty. This is an how I'm converting the responses to numbers: =IF([Question1]="Yes",3,IF([Question1]="N/A"," ",0))
So a response of (Yes, Yes, No, Yes, Yes) should convert to (1, 1, 0, 1, 1) which should = 4 out of 5. (80%)
The problem is how to calculate the grade so that if the an empty record doesn't factor into the calculation.
So a response of (Yes, Yes, No, Yes, N/A) should convert to (1, 1, 0, 1) which should = 3 out of 4. (75%)
I've got the conversion of the responses to numbers down pat, just can't get the calculation of the grade to work.

A True value is 1 and a False value is 0
So you can count the Yes strings (true) and the NOT N/A strings (number of Yes/No answers)
No need for any intermediate Calculations, all in one Column
=INT(AND(A1="Yes")+AND(A2="Yes")+AND(A3="Yes"))
/
INT(NOT(A1="N/A")+NOT(A2="N/A")+NOT(A3="N/A"))
*100
for less typing you can leave out the AND and just write (A1="Yes") which returns True. You can not leave out the NOT because we want a NOT(false) = true value to count all non-N/A columns

Related

SQL - Cast (String to NVARCHAR)

Row 4 - I'm trying to make the 'on' syntax, to the right of the = sign, dynamic. This is based on a two digit year value from any particular date (e.g., 2021-08-31'). Row 5, commented-out, displays the original logic. Row 4, to the right of the = sign, contains my attempt at dynamic logic.
Note, the actual date will eventually be supplied by a Date/Time parameter in MS Visual Studio (BIDS/SSRS).
Column Types: In row 5, a.cui = PK, varchar(8), not null. b.cy21_cui = nvarchar(30), null
SELECT 'b.cy'+substring('2021-08-31',3,2)+'_cui' = b.cy21_cui. This looks correct but the type is not... it is not the correct type and will not join to a.cui.
My question is, how do I CAST 'b.cy'+substring('2021-08-31',3,2)+'_cui' to a type that will join to a.cui? I've read all of the suggested threads here, based on the title of my question, and I cannot figure it out. I've testing a thousand CAST variations too.
Thanks in advance for any assistance.
1 select distinct bn
2 from fc_2021 a
3 join M..rx_crsw b
----------------------------------------------------------------------
4 on a.cui='b.cy'+substring('2021-08-31',3,2)+'_cui'
5 --on a.cui=b.cy21_cui
----------------------------------------------------------------------
6 join nf_bsc..cvrg c
7 on b.abc=c.abc
8 where a.Eff_Date<='2021-08-31' and a.term_date>='2021-08-31' and PA_Type<>0

IF Statement with multiple conditions and an overriding value

Thanks in advance for helping with this.
I have an issue where this I need the following formula to calculate this- i would advise seeing the picture in the link to fully understand the question (as I'm probably not going to explain myself!);
Calculating Risk Score
Condition 1: If Blood Result is less <=9 or Score <=6 or Tumour Size = <5mm show as text value Low
Condition 2 : If Blood Result 10-20 or Score = 7 or Tumour Size 5mm-9mm show as text value Medium
Condition 3: If Blood Result >=20 or Score = 8 or Tumour Size >=10mm show as text value High
The issue I am having is that any person can have a value from any of the condition, but I need to display the overriding value.
Example:
Blood Result = 5 (condition 1)
Score = 7 (condition 2)
Tumour Size = 10mm (condition 3)
SHOW VALUE: HIGH.
The problemn i'm having is that when I'm doing IF statements, as condition 1 of blood result is True, its always displaying Low without looking at the other values which could overwrite it.
I have only tried nested IF statements with AND OR in them, but no luck.
See examples of values
you can do one thing for that type condition
store your message in one variable, for example, var = msg
if condition 1 true assign msg = "Low"
if condition 2 true assign msg = "Medium"
if condition 3 true assign msg = "High"
after checking all conditions print your message.
I hope this will help you

How do I exit a for loop in python 2.7 without raising Exceptions

I have a for loop that iterates across a list of floats. My original intention was that I could do a for loop with an if statement to 'do stuff' if my data is > than x percentage…however I've come to realize that this method causes duplication of data presented. It IS factually right, but it is not what I desired nor intended. So, my mock data has something that is way larger than reality and it triggers the if condition on all lower percentages. I really just want it to trigger on the largest percentage and not onto the smaller conditions below…how would I do that in the most pythonic way possible?
This is the sample code solution I threw together but I think having to involve raising exceptions using a try/catch block is probably not as clean as other solutions.
#!/usr/bin/env python
percentages = [0.2,0.5, 0.75, 1, 2, 5]
resultingPercentage = 9
for i in sorted(percentages, reverse=True):
try:
if resultingPercentage > i:
print "We found an opportunity greater than %.2f%% points" %i
raise Exception
except:
#continue
break
Seeing as nobody else has posted it as an answer yet and to mark this question as answered, you can break out of a loop without the break statement appearing in an exception handler:
percentages = [0.2,0.5, 0.75, 1, 2, 5]
resultingPercentage = 9
for i in sorted(percentages, reverse=True):
if resultingPercentage > i:
print "We found an opportunity greater than %.2f%% points" %i
break
You can use the max function to get the largest percentage from the list, then just do a single if statement with only that percentage:
percentages = [0.2,0.5, 0.75, 1, 2, 5]
resultingPercentage = 9
maxPercentage = max(percentages)
if resultingPercentage > maxPercentage:
print "We found an opportunity greater than %.2f%% points" %maxPercentage

Make =IF Function Output Numbers For "Scoring": Google Sheets

I'm am exploring methods of giving scores to different datapoints within a dataset. These points come from a mix of numbers and text string attributes looking for certain characteristics, e.g. if Col. A contains more than X number of "|", then give it a 1. If not, it gets a 0 for that category. I also have some that give the point when the value is >X.
I have been trying to do this with =IF, for example, =IF([sheet] = [Text], "1","0").
I can get it to give me 1 or 0, but I am unable to get a point total with sum.
I have tried changing the formatting of the text to both "number", "plain text", and have left it as automatic, but I can't get it to sum. Thoughts? Is there maybe a better way to do this?
FWIW - I'm trying to score based on about 12 factors.
Best,
Alex
The issue here might be that you're having the cell evaluate to either the string "0" or the string "1" rather than the number 0 or the number 1. That would explain why you're seeing the right things but the math isn't coming out right - the cell contents look like numbers, but they're really text, which the summation would then ignore.
One option would be to drop the quotation marks and write something like this:
=IF(condition, 1, 0)
This has the condition evaluate to 1 if it's true and 0 if it's false.
Alternatively, you could write something like this:
=(condition) * 1
This will take the boolean TRUE or FALSE returned by condition and convert it to either the numeric value 1 (true) or the numeric value 0 (false).

Time based rotation

I'm trying to figure out the best way of doing the following:
I have a list of values: L
I'd like to pick a subset of this list, of size N, and get a different subset (if the list has enough members) every X minutes.
I'd like the values to be picked sequentially, or randomly, as long as all the values get used.
For example, I have a list: [google.com, yahoo.com, gmail.com]
I'd like to pick X (2 for this example) values and rotate those values every Y(60 for now) minutes:
minute 0-59: [google.com, yahoo.com]
minute 60-119: [gmail.com, google.com
minute 120-179: [google.com, yahoo.com]
etc.
Random picking is also fine, i.e:
minute 0-59: [google.com, gmail.com]
minute 60-119: [yahoo.com, google.com]
Note: The time epoch should be 0 when the user sets the rotation up, i.e, the 0 point can be at any point in time.
Finally: I'd prefer not to store a set of "used" values or anything like that, if possible. i.e, I'd like this to be as simple as possible.
Random picking is actually preferred to sequential, but either is fine.
What's the best way to go about this? Python/Pseudo-code or C/C++ is fine.
Thank you!
You can use the itertools standard module to help:
import itertools
import random
import time
a = ["google.com", "yahoo.com", "gmail.com"]
combs = list(itertools.combinations(a, 2))
random.shuffle(combs)
for c in combs:
print(c)
time.sleep(3600)
EDIT: Based on your clarification in the comments, the following suggestion might help.
What you're looking for is a maximal-length sequence of integers within the range [0, N). You can generate this in Python using something like:
def modseq(n, p):
r = 0
for i in range(n):
r = (r + p) % n
yield r
Given an integer n and a prime number p (which is not a factor of n, making p greater than n guarantees this), you will get a sequence of all the integers from 0 to n-1:
>>> list(modseq(10, 13))
[3, 6, 9, 2, 5, 8, 1, 4, 7, 0]
From there, you can filter this list to include only the integers that contain the desired number of 1 bits set (see Best algorithm to count the number of set bits in a 32-bit integer? for suggestions). Then choose the elements from your set based on which bits are set to 1. In your case, you would use pass n as 2N if N is the number of elements in your set.
This sequence is deterministic given a time T (from which you can find the position in the sequence), a number N of elements, and a prime P.