Home > Back-end >  How to auto-populate multiple columns based on an index of random 1's and 2's
How to auto-populate multiple columns based on an index of random 1's and 2's

Time:07-20

I have changed this question and the correct working answer to reflect explicitly the solution for my exact problem.

This is for accounting purposes. I'm trying to create a debit and a credit table so that I can keep track of payments and have balanced books for my business partner.

I thought to try =if(1, value) in the credit and debit tables however I will get a whole lot of cells of FALSE return values when it discovers values of 2 and vice versa which is not practical.

I have rows of information which I designate a type either 1 or 2. For example:

type description amount date comment
2 cable 50 12 May 1.0mm flat
1 payment 001 30 24 May
2 plugs 10 8mm size
2 bits and pieces 15
1 payment 002 20 30 May

I have a debit and credit columns in another sheet so what I want to happen is I want each line of the first table and any new line added thereafter sorted into a credit column and a debit column automatically.

Description Date Comment Credit type amount
payment 001 24 May 1 30
payment 002 30 May 1 20
Description Date Comment Debit type amount
cable 24 May 50 2 1.0mm flat
plugs 10 2 8mm size

I understand that there must be formula in the credit and debit type cells. I need some kind of sorting system.

CodePudding user response:

Many ways to do that.

If you need just one table use

=SORT(A2:C8,1,1)

OR EVEN

=QUERY(A1:C8,"where A is not null order by A",1)

enter image description here

If you need two tables just use it twice

One can also use

=QUERY(A1:C8,"where A=1 order by A",1)

AND

=QUERY(A1:C8,"where A=2 order by A",1)

(Do adjust the formulae according to your ranges and locale)

enter image description here

CodePudding user response:

Credit to @marikamitsos and theartsnettutors with the earth for giving me confidence to resolve this problem and giving me the tools to figure it out for myself.

The best tool to use is QUERY using the SELECT function and then selecting the columns from the RAW data table in the order that you want the data printed:

RAW data:enter image description here

Solution for CREDIT table: enter image description here

Solution for DEBIT table: enter image description here

  • Related