Forum Discussion

KunalGoel9911's avatar
KunalGoel9911
Copper Contributor
Dec 05, 2023

Combining only positive and negative numbers without using pivot data

https://docs.google.com/spreadsheets/d/1U0RxyQ4ycbXkNgGDwLDHBc4j0UG9-QIS/edit?usp=drive_link&ouid=104556168061891244163&rtpof=true&sd=true 

 

How can get the desired result as presented in the workbook without using the pivot table.

I want the combined positive values in one cell and combined negative values in another cell.

  • Lorenzo's avatar
    Lorenzo
    Dec 05, 2023

    KunalGoel9911 

     

     

    in D8 (make sure E8, D9 & E9 contain nothing):

    =LET(
      particulars,  UNIQUE(Table1[Particulars]),
      amounts,      SUMIF(Table1[Particulars], particulars, Table1[Amount]),
      positives,    SUM( IF(amounts >= 0, amounts) ),
      negatives,    SUM( IF(amounts < 0, amounts) ),
      HSTACK(
        {"Positives";"Negatives"},
        VSTACK(positives, negatives)
      )
    )
    • KunalGoel9911's avatar
      KunalGoel9911
      Copper Contributor

      Thank you so much for replying.

      As I can see, you have removed the need for pivot table but what I need is a single formula to be applied directly to the table in order to get the results in E8 & E9. Can you help me with that that formula??

       

      Also, using Microsoft 365


      Thanking in advance.

      • Lorenzo's avatar
        Lorenzo
        Silver Contributor

        KunalGoel9911 

         

         

        in D8 (make sure E8, D9 & E9 contain nothing):

        =LET(
          particulars,  UNIQUE(Table1[Particulars]),
          amounts,      SUMIF(Table1[Particulars], particulars, Table1[Amount]),
          positives,    SUM( IF(amounts >= 0, amounts) ),
          negatives,    SUM( IF(amounts < 0, amounts) ),
          HSTACK(
            {"Positives";"Negatives"},
            VSTACK(positives, negatives)
          )
        )

Resources