I have data like below:
1 2 3 A B C
4 5 6 A B C
7 C
3 4 B C
8 9 C B
1 2 3 C A B
The values 1-9 are assigned to values A, B, C - so for instance in first row A=1, B=2, C=3 etc.
I need to summarize all the elements above to get A, B, C.
How to start with this problem?
Final results:
A 7
B 22
C 29
Edit:
https://docs.google.com/spreadsheets/d/1kzOtV9_SE5s7DaA_6YcZq6z08FpfXaIAjukyISew49U/edit?usp=sharing
This should do your summary provided the ranges are the same dimensions.
=QUERY({FLATTEN(Arkusz1!F2:H)\FLATTEN(Arkusz1!B2:D)};"select Col1,SUM(Col2) where Col1<>'' group by Col1 order by SUM(Col2) desc label Col1'Summary'")
It is installed in a new tab called MK_Help
Related
a
b
c
d
e
f
result
1
q
4
r
q
2
w
5
t
w
3
e
6
e
r
7
r
8
r
t
Column ranges must be used from row 3 to the entire row.
The range referring to the image is B3:B column, D3:D column. Please ignore columns A and C.
The result must not contain blank cells.
Try:
=QUERY(FLATTEN(TRANSPOSE(FILTER(A3:D,MOD(COLUMN(A3:D),2)=0))),"where Col1 is not null")
I have a Google sheets with the following layout
Key Points Category Done
1 4 A Yes
2 4 B
3 1 B
4 5 C Yes
5 7 D Yes
6 4 B
7 2 C Yes
I need a formula that can sum the points based on category if the Done is "yes". So the output should be
Points done Category
7 C
4 A
7 D
Whch formula can I use for this? (I don't want to use pivot table)
try:
=QUERY({A2:D}; "select sum(Col2),Col3 where Col4 = 'Yes' group by Col3 label sum(Col2)''")
In a google spreadsheet I have 2 column pairs, EAN + number in stock
Some EAN's are present in both column A and C, some only in column A column and some only in column B.
Eaxmple:
A B C D E F
8573489753888 1 8729029847359 2
8789026119040 1 8434234872389 1
8789026118692 3 8789026118609 2
8729029847359 1 8789026118692 1
I need to find EAN's present in both column A and C and calculate the stock difference (column B and D). The result should be listed in column E and F.
I created a script that does this, but since I keep hitting the max execution time (the list is getting long), I am hoping this could be done without a script as well.
The results should be as follows:
A B C D E F
8573489753888 1 8729029847359 2 8789026118692 2
8789026119040 1 8434234872389 1 8729029847359 -1
8789026118692 3 8789026118609 2
8729029847359 1 8789026118692 1
full diference:
=ARRAYFORMULA(QUERY({A1:B; C1:C, D1:D*-1},
"select Col1,sum(Col2)
where Col1 is not null
group by Col1
label sum(Col2)''", 0))
reverse:
relevant diference:
=ARRAYFORMULA(QUERY({A1:B, IFERROR(VLOOKUP(A1:A, C1:D, 2, 0))},
"select Col1,Col2-Col3
where Col3 is not null
label Col2-Col3''", 0))
reverse:
Nice solution. I tried just with vlookup and it gets really complicated: =IF(ISNA(VLOOKUP(E1;A:B;2;FALSE()));IF(ISNA(VLOOKUP(E1;C:D;2;FALSE()));0;VLOOKUP(E1;C:D;2;FALSE()));VLOOKUP(E1;A:B;2;FALSE())-IF(ISNA(VLOOKUP(E1;C:D;2;FALSE()));0;VLOOKUP(E1;C:D;2;FALSE()))
I have 4 columns with values (A and C are products that mostly overlap, B and D are counts. What I'd like to do is for the values that occur in both A and C calculate the difference between B and D, and put the result in E and F.
So for example 5028421938592 count is 6 in column B and count is 2 in column D.
The result would be then be in column E: 5028421938592 and column F: 4
5028421928548 3 5028421928548 1
5028421938592 6 3259190205192 7
5028421997131 1 5028421938592 2
5028421995748 4 5028421995748 1
I suggest in E1:
=unique(query({A:B;C:D},"select Col1 where Col1 is not null order by Col1"))
and in F1 and copied down to suit:
=iferror(vlookup(E1,A:B,2,0),0)-iferror(vlookup(E1,C:D,2,0),0)
How do you "unpack" an array valued column in kdb ?
I have a table T which includes an array-valued column C,
and want a result with each the rows of T duplicated as many times as it has entries in the column C, with each duplicate containing one of the values from that column.
In PostgreSQL this would be a "lateral join".
Assuming you have the following table:
t:([]a:`a`b`c`d;b:(1,();(2;3);4,();(5;6;7)))
t
a b
-------
a ,1
b 2 3
c ,4
d 5 6 7
And you want duplicated rows for each value in column b, you can use UNGROUP to get:
q) ungroup t
a b
---
a 1
b 2
b 3
c 4
d 5
d 6
d 7
The simplest way to flatten nested columns is with the ungroup command. This command will work where multiple nested columns exist, provided the lists in each row have the same length.
q)show tab:([]a:`a`b`c;b:(1#`d;`e`f;`g`h);c:(1#1;2 3;4 5))
a b c
----------
a ,`d ,1
b `e`f 2 3
c `g`h 4 5
q)ungroup tab
a b c
-----
a d 1
b e 2
b f 3
c g 4
c h 5
The downsides to this approach are that all nested columns are ungrouped and if there are different length lists in each row then the command will fail:
q)show tab2:([]a:`a`b`c;b:(1#`d;`e`f;`g`h);c:(1#1;2 3;1#4))
a b c
----------
a ,`d ,1
b `e`f 2 3
c `g`h ,4 / different length lists
q)ungroup tab2
'length
[0] ungroup tab2
^
One possible solution to ungroup by a single column is the following, which duplicates each row by the number of elements in each c value:
q)f:{[t;c]#[t where count each r;c;:;raze r:t c]}
q)f[tab2;`c]
a b c
--------
a ,`d 1
b `e`f 2
b `e`f 3
c `g`h 4