1
votes

I would like to combine 2 result in one, to make them display in 2 column

what I have:

+------------+------------+------------+------------+------------+------------+------------+
|      B     |      C     |      D     |      E     |      F     |      G     |      H     |
+------------+------------+------------+------------+------------+------------+------------+
| Supplier A |    40ft    |   19-0201  | 02/09/2019 | 05/09/2019 | 05/09/2019 |  $2,590.60 |
| Supplier B |    20ft    |   19-0206  | 04/09/2019 | 06/09/2019 | 07/09/2019 |  $7,198.10 |
| Supplier C |    40ft    |   19-0208  | 04/09/2019 | 06/09/2019 | 07/09/2019 |  $3,673.40 |
| Supplier B |    20ft    |   19-0207  | 04/09/2019 | 07/09/2019 | 08/09/2019 |  $5,592.20 |
| Supplier C |    20ft    |   19-0203  | 06/09/2019 | 05/09/2019 | 06/09/2019 |    $863.30 |
| Supplier B |    20ft    |   19-0204  | 05/09/2019 | 05/09/2019 | 06/09/2019 |  $4,190.20 |
| Supplier D |    28ft    |   19-0205  | 05/09/2019 | 07/09/2019 | 08/09/2019 |  $1,390.60 |
| Supplier E |    14ft    |   19-0209  | 07/09/2019 | 09/09/2019 | 09/09/2019 |    $180.30 |
| Supplier B |    10ft    |   19-0211  | 08/09/2019 | 08/09/2019 | 09/09/2019 | $12,392.80 |
| Supplier C |    40ft    |   19-0210  | 07/09/2019 | 10/09/2019 | 11/09/2019 |  $6,591.30 |
| Supplier B |    20ft    |   19-0202  | 03/09/2019 | 12/09/2019 | 13/09/2019 |  $1,380.50 |
| Supplier F |    14ft    |   19-0213  | 09/09/2019 | 12/09/2019 | 12/09/2019 |  $4,576.30 |

this is first query code :

=ARRAYFORMULA(TEXTJOIN(CHAR(10),TRUE,SUBSTITUTE(TRIM(TRANSPOSE(QUERY(TRANSPOSE(QUERY(B16:H34,"SELECT B, D, SUM(H) GROUP BY B, D ORDER BY B ASC LABEL SUM(H)'' FORMAT SUM(H) '$##,##0.00' ")),,COLUMNS(QUERY(B16:H34,"SELECT B, D, SUM(H) GROUP BY B, D ORDER BY B ASC LABEL SUM(H)'' FORMAT SUM(H) '$##,##0.00' ")))))," → "," → ")))&CHAR(10)&CHAR(10)&"Total Costing : "&TEXT(SUM(H16:H34),"$0,000.00")

+-----------------------------------+
| Supplier A     19-0201  $2,590.60 |
| Supplier B     19-0202  $1,380.50 |
| Supplier B     19-0204  $4,190.20 |
| Supplier B     19-0206  $7,198.10 |
| Supplier B     19-0207  $5,592.20 |
| Supplier B     19-0211 $12,392.80 |
| Supplier C     19-0203    $863.30 |
| Supplier C     19-0208  $3,673.40 |
| Supplier C     19-0210  $6,591.30 |
| Supplier D     19-0205  $1,390.60 |
| Supplier E     19-0209    $180.30 |
| Supplier F     19-0213  $4,576.30 |
|                                   |
| Total Costing          $50,618.60 |

and my second query code :

={QUERY({B16:H34},"SELECT Col1, SUM(Col7)/"& SUM(H16:H34)&" WHERE Col1 IS NOT NULL GROUP BY Col1 LABEL SUM(Col7)/"& SUM(H16:H34)&"'Scale Of Amount' FORMAT SUM(Col7)/"& SUM(H16:H34)&"'(0.00%)'");"Total Costing Scale","(100%)"}

+---------------+--------------+
|               | SUM of Amount|
+---------------+--------------+
| Supplier A    |      (5.12%) |
| Supplier B    |     (60.75%) |
| Supplier C    |     (21.98%) |
| Supplier D    |      (2.75%) |
| Supplier E    |      (0.36%) |
| Supplier F    |      (9.04%) |
| Total Costing |    (100.00%) |

How to make it show :

+-------------------------+-------------------------+
|                         |      SUM of Amount      |
+-------------------------+-------------------------+
| Supplier A     19-0201  |  $2,590.60      (5.12%) |
| Supplier B     19-0202  |  $1,380.50              |
| Supplier B     19-0204  |  $4,190.20              |
| Supplier B     19-0206  |  $7,198.10              |
| Supplier B     19-0207  |  $5,592.20              |
| Supplier B     19-0211  | $12,392.80     (60.75%) |
| Supplier C     19-0203  |    $863.30              |
| Supplier C     19-0208  |  $3,673.40              |
| Supplier C     19-0210  |  $6,591.30     (21.98%) |
| Supplier D     19-0205  |  $1,390.60      (2.75%) |
| Supplier E     19-0209  |    $180.30      (0.36%) |
| Supplier F     19-0213  |  $4,576.30      (9.04%) |
|                         |                         |
| Total Costing           | $50,618.60    (100.00%) |
1
Posting a sample should would be very helpful!Matt

1 Answers

0
votes

This the formula that can be used:

=arrayformula({query( sort ( unique({B2:B,D2:D,sumif(B2:B&":"&D2:D,"=" &
  B2:B&":"&D2:D,H2:H)}),1,true,2,true),"Select * where Col1 is not null"), 
  iferror(vlookup(transpose(split(join(",",rept("0,",query(filter(B2:B,B2:B<>""),
  "Select Count(Col1) group by Col1 label Count(Col1) ''")-1) & 
  sequence(counta(unique(B2:B)))),",",true,false)), 
  {sequence(counta(unique(B2:B))), 
  query( unique({B2:B,sumif(B2:B,"="&B2:B,H2:H)/sum(H2:H)}),
         "Select Col1, Col2 where Col1 is not null")},3,false),"");
  {"Total","",sum(filter(H2:H,H2:H<>"")),1}})

Update 1:

= arrayformula
  (
    { 
      query (sort (unique({B2:B,D2:D,sumif(B2:B&":"&D2:D,"=" & B2:B&":"&D2:D,H2:H)}),1,true,2,true),"Select * where Col1 is not null"),
      iferror (
        vlookup(transpose(split(join(",",
          rept
          (
            "0,",query(unique(filter({B2:B,B2:B&":"&D2:D},B2:B<>"")),"Select Count(Col1) group by Col1 label Count(Col1) ''")-1
          ) & sequence (counta(unique(B2:B)))),",",true,false)),
          {
            sequence(counta(unique(B2:B))), 
            query (unique ({B2:B,sumif(B2:B,"="&B2:B,H2:H)/sum(H2:H)}),"Select Col1, Col2 where Col1 is not null")
          },3,false
        ),""
      ) ; {"Total","",sum(filter(H2:H,H2:H<>"")),1}
    }
  )