[Solved] Create a compilation from a table

Discuss the spreadsheet application
Post Reply
Albireo
Posts: 113
Joined: Wed Apr 15, 2009 12:05 pm

[Solved] Create a compilation from a table

Post by Albireo »

Since I can not get Pivot Tables to work smoothly in LibreOffice.
I have to find another way, to solve my desires...

The source table is in Column A-E
In this example, the table is sorted in column A - (Should it be sorted to make the formulas work?)
Structure of my wish
Structure of my wish
My wish is to find formulas to create results similar to 1-3. (Primarily 1a-3a)
The result does not have to be in ascending order - (if that would make it easier)
If it becomes easier to create suitable formulas, it is no problem to use a number of cells for each formula.

Result 1a (and 2a) are quite similar in their structure.
Result 3a is more complicated. (because it is not the same size on all intervals).
In my case, all intervals (about 10 pcs) have a name. All ranges are between 1000-9999 (four digits).

Result 1b - 3b Has expanded the compilation with calculations and units (not important in the first place)

Is my desire possible?
Is my desire complicated?
How to solve this?
( I have no idea what formula to use this case )
Formula - Compile results.ods
File with the data
(17.23 KiB) Downloaded 92 times
Last edited by MrProgrammer on Sun Feb 27, 2022 7:47 pm, edited 1 time in total.
Reason: Tagged ✓ [Solved] (using Pivot Tables) -- MrProgrammer, forum moderator
OOo 4.1.X on Windows XP, Win7, 10
User avatar
JohnSUN-Pensioner
Volunteer
Posts: 876
Joined: Fri Jan 14, 2011 1:21 pm
Location: Kyiv, Ukraine

Re: Create a compilation from a table

Post by JohnSUN-Pensioner »

I'm not sure about the values of cells G24 and M24 - is "1999" a typo?
I may not have a lot to give but what I got I'll give to you...
Apache OpenOffice 4.1.5, LibreOffice 6.4.4.2 (x64) on Windows 7
If you think that I did not answer your question, make allowances for my imperfect English
Albireo
Posts: 113
Joined: Wed Apr 15, 2009 12:05 pm

Re: Create a compilation from a table

Post by Albireo »

Excuse me! - (it should be 1099)
Has added a table with the different boundaries (and names for the test)
(Maybe it's easier to handle the borders if you start from a table?)
Table with groupnames
Table with groupnames
Category table.png (1.96 KiB) Viewed 1630 times
Also added a compilation 4b with names from the group name table.
(but the most important are 1a and 2a)
The group names are not as structured (in numerical order) and do not have as consistent names as in the test file.
Compilation 4b with names from the group name table
Compilation 4b with names from the group name table
Table with the group names.png (6.46 KiB) Viewed 1620 times

Formula - Compile results.ods
Testfile
(19.39 KiB) Downloaded 90 times
OOo 4.1.X on Windows XP, Win7, 10
User avatar
JohnSUN-Pensioner
Volunteer
Posts: 876
Joined: Fri Jan 14, 2011 1:21 pm
Location: Kyiv, Ukraine

Re: Create a compilation from a table

Post by JohnSUN-Pensioner »

Please take a look at this solution.
Pivot tables are not used here, everything is done using formulas.
For each of the tables, values without duplicates were selected from the original data. Used a trick that @MrProgrammer demonstrated five years ago
Everything else is the most common, "everyday" functions: IF(), SUMIF(), VLOOKUP(), OFFSET()...
Oh yes! For Res 3b and Res 4b tables, all values are displayed - to hide unnecessary rows, you can use an autofilter with the "Price without zeros" condition
Attachments
Formula - Compile results (1).ods
Without PivotTable
(21.27 KiB) Downloaded 95 times
I may not have a lot to give but what I got I'll give to you...
Apache OpenOffice 4.1.5, LibreOffice 6.4.4.2 (x64) on Windows 7
If you think that I did not answer your question, make allowances for my imperfect English
Albireo
Posts: 113
Joined: Wed Apr 15, 2009 12:05 pm

Re: Create a compilation from a table

Post by Albireo »

Thank you!
A somewhat impressive solution ...
I have to try to understand the instruction =OFFSET() (on Swedish =FÖRSKJUTA :) )
(What does it do in your example? - I see it works - but how)
Looked at another example that @MrProgrammer had done Sorting and Filtering data with formulas - had also used "= OFFSET()" in a MAX / MIN context.
Worked with his example - but did not work when I would implement OFFSET() in my testfile (maybe it was problem to understad how to use MAX / MIN ... I don't know right now.)

Did not know if any solution would be presented, so I tried another way ...
When I stopped grouping the pivot tables, and when all the fields in a column have the same formatting (number or text or...) - I like Ctrl + F8 very much - the problems with the pivot tables stopped. So if the source is good, Pivot tables work flawlessly - great! :D

To create the grouping information, a table was created with min- and max- values as well as text content (Maybe there are better ways than to create a long IF statement?)
This is my If - instruction ;) .:

Code: Select all

=OM($A5<$Info.$B$9;$Info.$D$8;OM($A5<$Info.$B$10;$Info.$D$9;OM($A5<$Info.$B$11;$Info.$D$10;OM($A5<$Info.$B$12;$Info.$D$11;OM($A5<$Info.$B$13;$Info.$D$12;OM($A5<$Info.$B$14;$Info.$D$13;OM($A5<$Info.$B$15;$Info.$D$14;OM($A5<$Info.$B$16;$Info.$D$15;OM($A5<$Info.$B$17;$Info.$D$16;OM($A5<$Info.$B$18;$Info.$D$17;$Info.$D$18))))))))))
In the example file, the formula would be something similar
= OM (A2 <L3; M3; OM (A2 <L4; M4; OM (A2 <... etc.) and be placed in column F
(I return with the result - have no time now)
OOo 4.1.X on Windows XP, Win7, 10
User avatar
Villeroy
Volunteer
Posts: 31345
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Create a compilation from a table

Post by Villeroy »

Albireo wrote:A somewhat impressive solution ...
However wrong. You must not sum up the prices. 2 pieces @ 55 is not 2*110.
Open the attached document. Open the embedded form.
Attachments
t107126.odb
(26.6 KiB) Downloaded 94 times
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Albireo
Posts: 113
Joined: Wed Apr 15, 2009 12:05 pm

Re: Create a compilation from a table

Post by Albireo »

Thanks!
@Villeroy - you have right (I did not see the calculation error)
Using a database is a very flexible solution.
The layout of the result is very easy to control. (I know)

But... I still have a little hard time in this case to see the benefits.
Last time (many years ago) I started using databases with OO / LO, but then there were so many bugs and weak support that I had to give up.
I have some projects that need to be solved with a database. - but that's another challenge.

The document I am working on is only relevant for a short time.
Actually, all data is completely static - it is only what is to be presented and how it is to be presented that can be changed.

A brief description of the background .:
In this case I have four CSV-files (with the same structure but different content) from two places. (= eight source files)
Now these files are on one page each in a spreadsheet.
In the same spreadsheet there also are four sheets with a brief summary of the other eight sheets. (Now I added another sheet with the table of groups.)
All in one file (its - great).

The source information (in this case) contains between 1 to 500 rows and 10 columns of information.
To make it easier to get an overview of this information, I would like a compilation of suppliers and groups.
(It is with this compilation that I have struggled with - I did in a different way before that were very time consuming)

Thanks @Villeroy for mentioning pilot- / pivot- tables (I was giving up - because I could not get several different tables to work on the same page.) - Now it seams to work.

Back to my idea to solution (right now)
This is now the source. Added two columns
  • Amount (Quantity * Price)
  • Category Name
    (=OM($A14<$E$4;"Invalid"; OM($A14<$F$4;$G$4; OM($A14<$F$5;$G$5; OM($A14<$F$6;$G$6; OM($A14<$F$7;$G$7; OM($A14<$F$8;$G$8; OM($A14<$F$9;$G$9; OM($A14<$F$10;$G$10;"Invalid" )))))))))
The test information
The test information
After that, it became easy to use pivot tables to make desired structure.
Examples of results with pivot tables
Examples of results with pivot tables
Do not know if it is possible to improve all IF statements to group the different rows - but it works.
(The IF-instruction will be long - about 500 characters)

What now could be improved is to display data from these individual pages to the compilation pages.
Right now I see no other solution than to manually copy data from the pivot tables
- and add information (like different VAT rates), units and do some calculations and maybe a chart.

Managed to find out how GETPIVOTDATA() works. but fails to copy information from a pivot table with unknown contents.

An updated test file is attached.
Formula - Compile results ver2.ods
A new testfile
(22.7 KiB) Downloaded 83 times
OOo 4.1.X on Windows XP, Win7, 10
User avatar
Villeroy
Volunteer
Posts: 31345
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Create a compilation from a table

Post by Villeroy »

Albireo wrote: But... I still have a little hard time in this case to see the benefits.
It simply works correctly and effortlessly. Just open the John's spreadsheet and my form side by side to see the difference. Then start adding data and see what happens in the spreadsheet and in the database form.
Albireo wrote:I have some projects that need to be solved with a database. - but that's another challenge.
No, it is exactly the same challenge. You waste hundreds of hours strggling with the wrong tool.
Albireo wrote:Last time (many years ago) I started using databases with OO / LO, but then there were so many bugs and weak support that I had to give up.
Why don't you give up so quickly on spreadsheets? You insist in solving problems that are not relevant. Why don't you simply put your pivot tables on separate sheets if you found out that there is a strange problem with pivots on the same sheet?

There may be far better database tools than Base, however the bugs in Base do not affect the underlying database (HSQL, MySQL, H2, PostgreSQL or whatever). Database programs have a much higher level of quality. I can work around Base bugs quite well as long as I can handle the underlying database software. If Base does not work this way, I usually find another way how it works. If not, I can still drag my record set into Calc and solve the problem there (cross-tables and charts for instance). Base is extremely simple. It has by far less features than Calc or Writer. But the tiny set of built-in features is tailored around the task of dealing with relational database tables. Calc serves a completely different purpose.

We are discussing amateurish solutions here. There is no reason to expect a maximum level of perfection and user convenience. Nevertheless, I consider spreadsheets inacceptable for anything related to record sets. I insist that a home brew solution should be correct and managable.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Post Reply