简体   繁体   中英

Distinct count using countifs in excel

I have a following excel data format:

ID       Category      Type
P-1      A1            Pro
P-2      A2            Demo
P-3      A2            
P-4      A1            Pro
P-4      A1            Pro
P-5      B1            Pro
P-6      B3            Demo

Using the above excel I need to create the following format and get count.

Category    Pro    Demo    Blank
A1          2      1       0
A2          0      0       1
B1          1      0       0
B3          0      1       0

I'm using =SUMPRODUCT(1/COUNTIFS()) but it is not working as expected.

Formula I used-

E2 =UNIQUE(B2:B8)
F2 =--(COUNTIFS($B$2:$B$8,$E2,$C$2:$C$8,F$1)>0)
G2 =--(COUNTIFS($B$2:$B$8,$E2,$C$2:$C$8,G$1)>0)
H2 =--(COUNTIFS($B$2:$B$8,$E2,$C$2:$C$8,"")>0)

在此处输入图像描述

You can use countifs

E2    =UNIQUE(B2:B8)
F2    =COUNTIFS($B$2:$B$8,$E2,$C$2:$C$8,F$1)  
G2    =COUNTIFS($B$2:$B$8,$E2,$C$2:$C$8,G$1)
H2    =SUM(COUNTIF($B$2:$B$8,$E2)-$F2-$G2)


A        B             C        D      E             F        G         H
ID       Category      Type            Category      Pro      Demo      Blank
P-1      A1            Pro             A1            3        0         0
P-2      A2            Demo            A2            0        1         1
P-3      A2                            A3            1        0         0
P-4      A1            Pro             A4            0        1         0     
P-4      A1            Pro
P-5      B1            Pro
P-6      B3            Demo

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM