IF parameter statement merged with time format - if-statement

I am trying to do an IF statement based on the parameter (Average or Total). However I am struggling with how to put the two together.
=Floor(Sum(Fields!Avg_ACD_Time.Value)/ 3600) &":"& Format(DateAdd("s",Sum(Fields!Avg_ACD_Time.Value), "00:00"), "mm:ss")
=IIF(Parameters!ReportType.Value="Average", Sum(Fields!Avg_ACD_Time.Value)/CountRows(), Sum(Fields!Avg_ACD_Time.Value))
Many thanks

I think this should work:
=IIF(Parameters!ReportType.Value="Average",
Floor((Sum(Fields!Avg_ACD_Time.Value)/CountRows()) / 3600) & ":" & Format(DateAdd("s", Sum(Fields!Avg_ACD_Time.Value)/CountRows(), "00:00"), "mm:ss"),
Floor(Sum(Fields!Avg_ACD_Time.Value)/ 3600) &":"& Format(DateAdd("s",Sum(Fields!Avg_ACD_Time.Value), "00:00"), "mm:ss"))
You just need to replace the Sum(Fields!Avg_ACD_Time.Value) with Sum(Fields!Avg_ACD_Time.Value)/CountRows() for the average.

Related

Simplify google sheet formula "SUM / INDEX / MATCH"

I am trying to use google sheet to create a roster formula, to sum up the duty hour per week using INDEX/MATCH/SUM.
But it's too long, is there any way to simplify the formula?
Also, I realize "MATCH" cannot recognize blank cell (N20), can that be fixed too?
=IFERROR(SUM(INDEX($O$12:$O$20,MATCH(D17,$N$12:$N$20,0)),INDEX($O$12:$O$20,MATCH(E17,$N$12:$N$20,0)),INDEX($O$12:$O$20,AND(F17,$N$12:$N$20,0)),INDEX($O$12:$O$20,MATCH(G17,$N$12:$N$20,0)),INDEX($O$12:$O$20,MATCH(H17,$N$12:$N$20,0)),INDEX($O$12:$O$20,MATCH(I17,$N$12:$N$20,0)),INDEX($O$12:$O$20,MATCH(J17,$N$12:$N$20,0))),"Err")
try:
=ARRAYFORMULA(MMULT(IFERROR(REGEXREPLACE(UPPER(B6:H14), "^"&TEXTJOIN("$|^", 1, L1:L10)&"$",
VLOOKUP(REGEXEXTRACT(UPPER(B6:H14), "^"&TEXTJOIN("$|^", 1, L1:L10)&"$"), L1:M10, 2*
SIGN(ROW(A6:A14)), 0)&""), UPPER(B6:H14))*1, TRANSPOSE(COLUMN(B:H))^0))
Franco, since your post says your end goal is to "sum up the duty hour per week," I take that to mean all you need in the end is a single number.
Try this (which will give you total hours for your block that runs B6:H22:
=ArrayFormula(SUM(COUNTIF(B6:H22,$L$1:$L$8)*$M$1:$M$8))
If you need to see the breakdown per code, you can use this:
=ArrayFormula({$L$1:$L$8,COUNTIF(B6:H22,$L$1:$L$8)*$M$1:$M$8})
Just replace "B6:H22" with the reference of each calendar block to get the sum or the breakdown for other weeks.

SSRS Multiple IF SUM based on paramter

I've been struggling with this for a few hours if anyone can help.
=IIF(Parameters!Agent.Value ="Susan Calladine", (Sum(Fields!Susan_Calladine.Value) / Sum(Fields!InvitedToApply.Value),
IIF(Parameters!Agent.Value ="Fazaila Pirbhai", (Sum(Fields!Fazaila_Pirbhai.Value) / Sum(Fields!InvitedToApply.Value),
IIF(Parameters!Agent.Value ="Claire Willis", (Sum(Fields!Claire_Willis.Value) / Sum(Fields!InvitedToApply.Value),0)))
Basically to calculate specific fields based on the value of the parameter being returend
Since the error you're getting no doubt refers to a ')' being expected either add a closing ) to each of your SUM clauses
(Sum(Fields!Susan_Calladine.Value) / Sum(Fields!InvitedToApply.Value))
or get rid of the opening ( in each case
Sum(Fields!Susan_Calladine.Value) / Sum(Fields!InvitedToApply.Value).
Personally I'd go for the second as it will make the expression a little more readable

Crystal Reports Else If statement

I can't figure out why this if statement won't work.
I have a DateTime field DATEFROM and a String parameter (it HAS to be String) periodEnd.
I would like to calculate percentages depending if these two dates have 1, 2, 3 or more years difference.
When I use this formula I get either "100%" or "-" and never the other two options. It's like CR calculates the first IF and if it's true then: "100%" but if it's false, it never checks for the rest of the Else Ifs and goes dirreclty to Else
StringVar percentage:="";
If (cDate({?periodEnd})-{TABLE.DATEFROM})<=1 Then
percentage:="100%"
Else If (cDate({?periodEnd})-{TABLE.DATEFROM})<=2 Then
percentage:="66%"
Else If (cDate({?periodEnd})-{TABLE.DATEFROM})<=3 Then
percentage:="33%"
Else
percentage:="-"
Any idea?
a) I assume you already made sure your periodend format matches with what cdate interprets?
If you just subtract them, Crystal by default returns the number of days between.
Two ways you can do year:
datediff("yyyy",cDate({?periodEnd},{TABLE.DATEFROM})
or
year(cDate({?periodEnd})-year({TABLE.DATEFROM})
b) You've also no doubt accounted for when your {TABLE.DATEFROM} is greater than cDate({?periodEnd} and you have a negative result?
Not sure if the following is the behavior you would want, but I'm throwing it in for your information
ABS(datediff("yyyy",cDate({?periodEnd},{TABLE.DATEFROM}))
**make sure you check the help file for the datediff codes ("yyyy" etc) as they are not quite instinctive and can trip you up when you think you're using the obvious one

Permanent timer on Python

I have been recently working with Python, and I wish to make a program that tells me how long was the last time I inputted something without it closing (e.g. The first thing I input is the word "foo". After 15 minutes, I input foo again, so the program prints that I last inputted the word foo 15 minutes ago).
Any ideas on how to make such a script? (Thanks in advance)
Do you mean to tell you the last time you entered anything or a specific word?
If it's a specific one, make a dictionary where you use words as keys, and then store the time there.
Record the time using time.time() and every input() in a dictionary. Then record the time again the second time it is entered and take the difference in time. The difference is in seconds, so divmod() it by 60 to get the minutes and seconds.
import time
inputs = {}
while True:
i = input("Type something. ")
t = time.time()
if i in inputs: #The input was inputted previously
time_diff = t-input[i]
minutes, seconds = divmod(time_diff, 60)
print("You typed that", minutes, "minutes and", seconds, "ago")
inputs[i] = t

django query to calculate time

The following are the timestamps that is present in the timestamp column of the table userdata.My question is that how to write a query such that i get the output as i need the month name i.2,2010-03 and the total time used in the month
userdata.months.filter().order_by('-timestamp')
'2011-03-07 16:03:01'
'2011-03-07 16:07:04'
'2011-03-06 11:03:01'
'2011-03-08 16:03:01'
'2011-03-04 09:03:01'
'2011-05-16 16:03:01'
'2011-05-18 16:03:01'
'2011-07-16 12:03:01'
'2011-07-17 12:03:01'
'2011-07-17 15:03:01'
something like
my_month = 2 (or whatever you need)
userdata.months.filter(timestamp__month=my_month).aggregate(sum('timestamp__time')
i'm not sure about that timestamp__time, you may search a bit about it, but i think it's correct.
otherwise, you can use a raw query (userdata.months.raw('query here'))