LibreOffice Calc and Pivot table with empty cells - pivot-table

I want to process survey results with LibreOffice Calc (for example with data coming from LimeSurvey).
Since some questions were optional, some cells are empty (like A6):
I want to answer questions like:
How many people have given the answer 2?
How many people did not respond?
So, I've created a pivot table with Insert → Pivot:
but... I was not able to answer the question "How many people did not respond?" (see B6).
Actual bug:
the cell B6 counting empty cells is empty
Expected result:
the cell B6 counting empty cells should be 1 (sum of empty cells = 1)
To fix this problem I have a workaround consisting in creating a "temporary table" and replacing empty cells with something weird like § EMPTY VALUE § to then be able to analyze empty values with my pivot table.
How do you handle empty cells in LibreOffice Calc with a pivot table?
Tested on LibreOffice 6.4.7 on Debian GNU/Linux but I can reproduce on Ubuntu 20.04 Focal Fossa and on other operating systems.
Thank you so much!

Another workaround:
in column B, transform column A to string (the formula for cell B2 is =""&A2)
Then create the pivot table using the values in column B.

It seems LibreOffice has a known bug since 2012, involving pivot tables with empty cells.
https://bugs.documentfoundation.org/show_bug.cgi?id=47523
AFAIK, the described workaround, involving a temporary table, is the only known solution.
Note: since 2022 it seems there is an available patch under review that you can check:
https://gerrit.libreoffice.org/c/core/+/129088
Update 2023: the patch was abandoned and the bug is still there.

Related

how to sequence a set with reseting condition only if previous state got terminated

given the specific set of columns, I'm looking for a way to turn red cells into blank cells either within the COUNTIF process or afterward.
formula I use to get (partially) correct answer is:
=ARRAYFORMULA(IF(A2:A="",,IF(NOT(REGEXMATCH(TO_TEXT(B2:B), "\-")),
COUNTIFS(A2:A&D2:D, A2:A&D2:D, ROW(A2:A), "<="&ROW(A2:A)), )))
here is a copy of my sheet: - CC -
consider yellow cells as RESET/TERMINATION for ID
after each reset, ID gets upgraded (E column)
E column is just a helper for better visualization - it's not part of the dataset
A column is unsorted and it may be even ungrouped
When I make a copy of your sheet (the only option provided), the negative numbers in Col B are actually all text. So I didn't backtrack into the best way of doing this from the original data in Col A. Instead, I just worked with Cols A:D as you currently have them (though I suspect that you don't need the helpers) and with your original "close" formula as you wrote it.
That said, this should work to deliver your desired result as shown:
=ArrayFormula({"DESIRED OUTPUT";IF(A2:A="",,IF(VLOOKUP(A2:A&"~"&COUNTIFS(A2:A,A2:A,ROW(A2:A),"<="&ROW(A2:A))-1,{SPLIT(UNIQUE(A2:A)&"~0|0","|");A2:A&"~"&COUNTIFS(A2:A,A2:A,ROW(A2:A),"<="&ROW(A2:A)),C2:C},2,FALSE)<>0,,IF(NOT(REGEXMATCH(TO_TEXT(B2:B), "\-")), COUNTIFS(A2:A&D2:D, A2:A&D2:D, ROW(A2:A), "<="&ROW(A2:A)), )))})
My contribution is this part:
IF(VLOOKUP(A2:A&"~"&COUNTIFS(A2:A,A2:A,ROW(A2:A),"<="&ROW(A2:A))-1,{SPLIT(UNIQUE(A2:A)&"~0|0","|");A2:A&"~"&COUNTIFS(A2:A,A2:A,ROW(A2:A),"<="&ROW(A2:A)),C2:C},2,FALSE)<>0,, [most of your previous formula])
In plain English, this looks up the last occurrence of each ID. Only if that last occurrence had a 0 value in Col C will the results of your main formula be shown.
I stacked SPLIT(UNIQUE(A2:A)&"~0|0","|") on top of the actual ID~Row, Col C values so that the first occurrence of any ID will still find a 0 and will not result in an error. (Adding IFERROR would have unnecessarily lengthened the formula.)
NOTE 1: I assumed here that you original "close" formula works as you expect. I did not test it under close scrutiny. I just plugged it into my extended formula that determines where to place results.
NOTE 2: Normally, I don't get into complex formulas on these forums, for the sheer sake of time and the fact that I stay very busy. But you help out a ton on this forum, so I was happy to invest back into your own rare inquiry here.

Define range for sum/sumif with a formula

I've been going up and down the internet to solve this. I think I am not searching with the correct parameters but I still hope you can help me.
Sample table:
I have some consolidation forms I need to fill with sums. So, in C19 (which is actually on a new tab) I would like to sum all the values C5-C12 which are mapped to the AB100 account for the consolidation, in production for example. The AB100 account is not unique to production, so I first need to define the column in which the specific row(s) have to be used to sum the values. Automating that in a formula is my key issue here.
I could easily solve this by just selecting column E as range for SUMIF but I want the formula in C19 to be able to recognize which column is to be looked at automatically, e.g. by using a "Lookup Key". I have many of those consolidation forms and I don't want to manually change the formulas on each tab.
It seems to me that all tips I found for nested SUM(IF( or SUM(INDEX( - even as array formulas - have the result value on the intersection of matched row and column. What I have on that intersection is a range of identical account numbers which need to be matched back to their respective $ values in C5-C12.
Any idea how I can do this with a formula?
Use INDEX/MATCH
=SUMIF(INDEX(D5:F12,0,MATCH(C16,D4:F4,0)),B19,C5:C12)
Using an index formula to select the column required in the SUMIFS
Hope this helps!

SUM with IF conditions for cells containing both strings and numbers

I've got a bigger table with one column that I want to focus on, containing designation and a number. I want to simply sum the numbers that meet the criteria based on a designation.
For the simplification, I made an exercising sheet (on the pic) where I split second column into two - one string and one numeric. Since my file is quite large with many columns that would need this it would be inconvenient.
In the left column it's easy to solve the problem, it could be even easier with simple SUMIF function, but an array SUM(IF... function is, at least I think, only viable option here.
So I solved the first table with array function, but what confuses me is how to modulate the TRUE statement. Simple replacement of C:C
with
VALUE(MID(F:F;4;4))
which would format my cells to get the numbers from string does not work that way - returns zero in E12 field. F12 is just application of string to number for last cell, F10.
THIS formula does not work, even adapting to different versions of the tool.
I could use VB but if possible anyhow I would like to avoid it since parts will be shared on mobile phones.
Any ideas? Thanks a lot!
Left table was split, right original format
The array formula which you used can be replaced by the SumIf formula like below...
=SUMIF(B:B,"B",C:C)
Also without the helper column, you can use the Sumproduct formula to achieve the desired output.
But don't refer the whole column in the formula like in the above SumIf formula.
Try this..
=SUMPRODUCT((B1:B10="B")*MID(F1:F10,FIND(",",F1:F10)+1,255)*1)
Change the ranges as per your requirement but remember to make them equal in size.

How to arrange table data differently by using if, match, and index?

As shown in the attached image, I need to convert A2:D10 to the format of A12:E17. The 4 tables from F1 to AB12 are my experiments using if, match, and index. Same formula gets different results and it seems to be dependent on the row position of the tables. In My previous question, I was trying to pinpoint the problem to the if function.
What am I doing wrong here?
Thanks,
Lu
enter image description here
Again, as I said in your last question: The formula has not been array entered. Array formulas need to be confirmed with Ctrl-Shift-Enter.
Without that, the first array in the IF statement does not get resolved and the Match does not return the correct result.
Make use of the Evaluate Formula tool and step through the formula.
The merged cells don't help with the cell referencing. Unmerge the cells and fill in all the labels in row 1, then use this slightly amended formula and confirm it with Ctrl-Shift-Enter. Then copy across and down.
I hope that I get the English names of the functions right:
In D14 and following cells:
=INDEX($C$1:$C$5;MATCH(1;MMULT(($B$3:$B$10=$A14)*($A$3:$A$10=B$13);1);0))
The MATCH function tells which value (by number counted from the top) matches both conditions. The INDEX function returns this value from C1:C5.

turn a matrix into a sorted list google docs/spreadsheets

I've created a large-ish matrix by doing a =pearson( analysis on survey responses in google docs/spreadsheets and would like to convert it into a sorted list.
The matrix has labels (the survey questions) in row 2 and column b. Each intersecting cell has the value. Here's what the formula looks like.
=pearson(FILTER( Pc!$C$2:$AW$999 ; Pc!$C$2:$AW$2= C$2 ),FILTER(Pc!$C$2:$AW$999 ;Pc!$C$2:$AW$2=$B3))
This is what I'd like to get to:
a b c
Question one question 2 correlation
Then sorting by column c is easy.
How can I get all the points out of the matrix/array, along with the labels in this way?
Ideally I'd be able to do this only to points below the diagonal as there of course are dupes above..
Thanks!
I think I found a solution to placing the combination of the headers in a single column.
It involves a series of auxiliary columns, but works.
Let's say we have a single column with all unique headers on column A. I'll assume it's 6 values. So, on cell B1 we paste:
=ArrayFormula(join(";";A1&","&A2:A$6))
And then copy it down to B5. On C1 we join it all and split making a single column:
=transpose(split(join(";";B1:B5);";"))
If needed, we can split the combination in two columns again on D1
=ArrayFormula(split(C1:C15;","))
I don't know why, but the value on E1 does not work correctly, so I just pasted =A2
With these columns you can easily do your nice Pearson-Filter trick again to have it all in a single column. Hope this helps :)
Maybe something like this will help:
=ArrayFormula(transpose(split(CONCATENATE(transpose(C2:AW999)&char(9)), char(9))))
(C2:AW999 is your data range)

Resources