Iterating a function over several cells - libreoffice

I have a table of numbers that represent hours worked each day by several employees. Each cell is one day for one employee. Some cells include an "*" character denoting that those hours do not contribute to the departmental total. When calculating the departmental total, I simply do a sum of all the cells and calc ignores those values that include the asterisks. However, when I calculate the sum of the hours for the individual employee, I want to include those hours.
After doing some experimentation, I've arrived at the following clunky formula:
=SUM(VALUE(SUBSTITUTE(C22,"*","")),VALUE(SUBSTITUTE(D22,"*","")),VALUE(SUBSTITUTE(E22,"*","")),VALUE(SUBSTITUTE(F22,"*","")),VALUE(SUBSTITUTE(G22,"*","")),VALUE(SUBSTITUTE(H22,"*","")),VALUE(SUBSTITUTE(I22,"*","")))
While this works, it's terrible! Is there a way to iterate a set of functions over a set of cells? Something like:
=SUM(ITERATE_FUNCTION(VALUE(SUBSTITUTE(X,"*","")),C22:I22))
Or is there an easier way to accomplish my goal?
Thanks!

For Calc, there is one super-power function for working with multiple values: SUMPRODUCT. With a little creativity, it can do just about anything.
=SUMPRODUCT(VALUE(SUBSTITUTE(C22:I22;"*";"")))
It acts as an array function but Ctrl+Shift+Enter is not needed, making things much easier.

I believe this will work:
=SUM(NUMBERVALUE(SUBSTITUTE(CONCATENATE(D22:I22),"*","")))
Press CTRL-SHIFT-ENTER when you're finished typing it in so the formula becomes an array formula, the formula will then look like this:
{=SUM(NUMBERVALUE(SUBSTITUTE(CONCATENATE(D3:H3),"*","")))}

Related

Sorting a list according to date with missing date inserts

Sorry for the convoluted title, but I find it to be a convoluted propblem
I have two lists, one of dates and one of counts pr. date.
Like this:
I would like it to end up like this:
where the dates have been moved to their corresponding cell, according to the time between the two dates.
I would prefer it to be doable in Google Sheets, but if thats impossible, Excel would suffice.
Anyone have a clue of how to this?
You can create the sequence of all dates as proposed by #BigBen in the comment using SEQUENCE like this
=SEQUENCE(MAX($A$1:$A$3)-MIN($A$1:$A$3)+1;1;MIN($A$1:$A$3))
And then in the next cell you can insert the following formule
=ArrayFormula(IFERROR(VLOOKUP($C$1:$C;{$A$1:$B$3};2;FALSE)))

Cognos Report Studio - Grouping/Filtering

Truth be told I'm not entirely sure what it is I'm trying to do here, well, that is I know what I want to achieve, but not how to go about it... so here's hoping you can help point me in the right direction!
I need to create a Crosstab report which has customers down the side, dates for columns, sales for figures. Simple enough.
Where it gets tricky is that they then want another row beneath the customers which singles out two customers, and their sales for one particular product.
They then want another row which will remove that figure from the total of the overall sales total for the first section (see example image).
I'm not really sure where to even start with this. I think I may need to use a query union, but every time I start I get kinda stuck... help!
That's not a crosstab. The summary calculations don't work. It's probably going to end up being three crosstabs formatted to look like a single crosstab. The first crosstab is everything down to the Total line. The last two lines are each crosstabs. Set the Size & Overflow, Padding, Margin, and other formatting properties so everything is layed out, bolded, and shaded the way you want.
You can create this as a crosstab
If you are okay with setting each customer as a fact
You can add them to a crosstab in any order you want
Then you can create a new data item and use a conditional statement that sets the metric to be the specific customers the consumer wants
For example,
IF([Customer] IN(?PrmCust) Then([Sales])Else(0)
For the revised total, unlock the report and replace them with layout calculations that take the total and reduce it by the amount of the selected customers

How to return a cell value if the date in a range of cells is today in google sheets

I currently have a Google Sheet, with numerous sheets in it, to track contract deadlines for different clients. One of these sheets shows me all of the deadlines in Columns E:M for every contract. Each row is a separate contract.
I'm trying to create a separate sheet that will show me the client's name, found in column A, if a date in columns E:M is Today. That way I can look at one page and see all the clients that have a deadline today. Here is what I tried with no success:
=if('U/C(Dont Edit)'E2:M2=TODAY(),'U/C(Dont Edit)'A2,"")
"U/C(Dont Edit)" is the sheet that shows all of the contracts.
I believe the problem lies when I try to apply "=Today()" to a range(E:M). It seems to work fine if I just use E2=Today(). It looks like I could accomplish my goal using If statements within If statements, but that gets very messy very quickly and I'm hoping there is a better way.
Thanks in advance for your help.
You can do it with the COUNTIF() function per row:
=IF(COUNTIF(E2:M2,TODAY())>0,A2,"")
But I think a better solution is to use the FILTER() function. It will give you a list of names:
=FILTER(A2:A,(E2:E=TODAY())+(F2:F=TODAY())+(G2:G=TODAY())+(H2:H=TODAY())+
(I2:I=TODAY())+(J2:J=TODAY())+(K2:K=TODAY())+(L2:L=TODAY())+(M2:M=TODAY()))
I suggest #dePatinkin's solution (for and additional column, say N, containing the COUNTIF formula from Row2 downwards) in combination with a query (in another sheet):
=query('U/C(Dont Edit)'!A:N,"select * where N is not NULL")
This assumes your existing sheet has the columns labelled.
You might combine the above with Conditional formatting to indicate which column has the date in it (today) that triggered the row selection.

Repeating a crosstab element with different parameters

I'm a new BIRT user, and I've been having trouble trying to get the behavior I want for my report. I've created a vertically-oriented crosstab with row groupings on month + year. However, each grouping has completely different columns and this ends up with a lot of empty space. It looks like this:
Note all that empty space. It makes the report end up being huge, horizontally. I'd like it to be closer to something like this (quick mock-up):
Right now, the report is generated based on start and end date report parameters, and it looks fine with just one month. I was thinking I could have the crosstab in its entirety be repeated, each one with its own single-month time period, but I cannot find any way to do this. Would that be the correct way of doing this? Is there a better way?
I figured out how to do it. I made the crosstab a sub-report of a scripted dataset of time periods, and then filtered the crosstab on those time periods. Feels sort of hacky and I gotta think there's a better way of doing it, but at least I've got what I wanted.

SUMIFS with multiple criteria, one of which is a single day

I'm trying to get a formula that will break down the amount of times a user enters a contest each day.
I'm pretty new to this whole thing, basically putting it together using google to figure out the code I need to use/modify. Explaining why something works would be greatly appreciated so I can use it elsewhere!
Here's a dummy of the form I'm banging my head against.
I would like the form to be reusable, so on the Sorted form I have a date key that automatically fills out the week when you choose the first day. Because of this, I would like each formula to refer to this date key, instead of manually typing the google equivalent of 'February 1st, 2015' into the formula.
I've tried to use the SUMIFS formula, and I've run in to a few errors.
Apparently both pages have to be the same amount of rows, otherwise I get an 'Array arguments to SUMIFS are of different size'. I didn't want my 'sorted' sheet to be 1761 rows long, since all of the duplicate names will have been condensed and I wanted it prettier. Nuts to that! Guess I can hide the rows? Is there any other solution?
It looks like this works:
=SUMIFS(Entered!E3:E1000, Sorted!E3:E1000, Sorted!$E3, Entered!A3:A1000, date(Sorted!$C7))
Where entered!E: is the number of entries, sortedE: is the list of usernames, and E3 is the specific one I'm looking for. Then EnteredA3 is the list of dates and time, and Sorted!C7 is the specific date I'm looking for. I don't get any results!
If I click on my C7 and sorted!A, the little calender pops up, which means they are dates (I think?). One includes the hours:minutes:seconds and the other doesn't, which I think is my problem. I would like to have sorted!C7 be the entire day, and filter out all of those entries.
This is taking information entered via a google form which I won't have control of, so I can't really change the H:M:S additions to the date column.
Thinking ahead to day 2 and onwards, will the same formula work when sorted!C10 is C$7$+1? Is it not a date anymore?
I would also like to add up the amount of daily entries, in sorted!S7 and below. I've tried wrapping both the column of dates and the date from my day key in the date() thing, but it doesn't seem to work either.
=SUMIF(date(Entered!A3:A),date(Sorted!C7),Entered!E3:E)
It gives me a '1', and I have no idea where that comes from.
I haven't been able to find much about the google SUMIFS function, mostly how to replicate it from before it was a thing.
And for even MORE complexity:
I was wondering if it is possible to have UNIQUE find the IDs in entered!C, and return all the associated usernames. That pesky angelo changed their username to 'pants' midway through the contest, and I'd like to be able to see both names and add up both 'angelo' and 'pants' entries in the same line in my formulas.
I feel like I'll need a few hidden columns that have the UNIQUE ID number and the associated usernames that I pull into my Sorted!Username column, but I don't know how to search the IDs to find the different usernames.
I tried to google that, but I have no idea what I'm googling.
Whewph! That is a lot of questions, thanks for any help!
Too long for my taste, but you might try:
=sumifs(Entered!E:E,Entered!A:A,">="&$C$7,Entered!A:A,"<"&$C$7+1,Entered!B:B,$E3)
in Sorted!F3 and copied down to suit.
Oh my goodness, you are a hero!
My final code wound up being:
=IF(ISBLANK(Sorted!$E3)=TRUE, "", sumifs('Entered'!$E:$E,'Entered'!$A:$A,">="&$C$7,'Entered'!$A:$A,"<"&$C$7+1,'Entered'!$B:$B,$E3))
I changed the start and end points by making $C$7 into $C$7+1, and the ending one into +2. (In case anyone else is looking at this answer.)
I'm super pleased that it worked!
Using this I managed to add up each of the daily entries, just by adding up the columns they were in.
I gave up on the UNIQUE idea, if someone changes their username during the contest, then they can add up the two rows themselves.
Thanks again! I'd upvote you, but I can't yet.