Forum Discussion

BCowans's avatar
BCowans
Copper Contributor
Sep 05, 2023

Formula help please

Hello, 

I need help with a formula but I'm unsure if it's possible to do so. 

It will include a few different tabs. 

Tab one, I need the formula to pull the total percentage based off another tab.

 

Tab 1 example below

 RedOrangeYellowGreenBluePurpleBlackBrownWhite
          
1.1         
13.2         
14.1         
14.2         
1.13         

 

I would like for tab 1 to be able to give me the percentage based off tab 2 answers, 

For red, is there a way for it to give me a percentage based of the yes and no's. In this case it would 3/3 (100%)

 

tab 2 (1.1) example below

 Compliant
RedY
OrangeY
YellowN
GreenN
BlueY
PurpleN
BlackY
BrownN
WhiteY
RedY
OrangeY
YellowY
RedY
OrangeN
YellowN
PurpleY
BlackN
BrownY
BlueN
  
 58%
 11
 19

 

I hope this makes sense and thank you for any help. 

5 Replies

  • BCowans 

    I think SergeiBaklan 's code is version neutral.  I am the one who uses problems to explore what could be done that is specific to 365.  When I first embarked on this voyage of discovery, my solutions were pretty useless to the OP but now there is an increasing proportion of users who could use the solutions, even though they may fail to meet expectations.

     

    I had another look at the problem you specified today and finished up with

    = ArrayCountIfλ(tableBody, "Y", tableHeader, header, tableAttribute, color)
    
    where
    
    ArrayCountIfλ
    = LAMBDA(tbleBody, value, tbleHdr, hdr, tbleColor, clr,
        LET(
          mask,   ISTEXT(hdr) * ISTEXT(clr),
          hdrArr, IF(mask, hdr),
          clrArr, IF(mask, clr),
          MAP(hdrArr, clrArr, LAMBDA(h, c, COUNTIFS(XLOOKUP(h, tbleHdr, tbleBody), "Y", tbleColor, c)))
        )
      )

    One day and I might even get to use it myself!

  • BCowans 

    Something of an effort to bypass Microsoft's array of array specification error by using MAP over a 2D array.

    = LAMBDA(hdr,clr,table,
        LET(
          tbleHdr,   TAKE(table, 1,-2),
          tbleBody,  DROP(table, 1, 1),
          tbleColor, DROP(table, 1,-2),
          mask,      ISTEXT(hdr)*ISTEXT(clr),
          hdrArr,    IF(mask, hdr),
          clrArr,    IF(mask, clr),
          MAP(hdrArr, clrArr, LAMBDA(h,c, COUNTIFS(XLOOKUP(h, tbleHdr, tbleBody), "Y", tbleColor, c)))
        )
      )(header, color, Table1[#All])

     

  • BCowans 

    Depends on which Excel version you are, below possibly could work on practically any one. If second range is named answers

    here

    in C4 it could be

    =SUMPRODUCT(
        (INDEX(answers,0,1)=C$2 )*
        (INDEX(answers, 0, MATCH($B4, INDEX(answers,1,0), 0) ) = "Y" ) )
        /
        SUMPRODUCT( 1*(INDEX(answers,0,1)=C$2) )

    and drag it to the right and down.

    • BCowans's avatar
      BCowans
      Copper Contributor
      I think our versions are different because it didn't convert over. Thank you though!
      • BCowans 

        If you mean Excel version above formula shall work on practically any one. The only is how your data is structured exactly and how do you name the ranges.

Resources