Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Want to see what's currently in public preview? We've pulled it all together in one place. Check it out here
cancel
Showing results for 
Search instead for 
Did you mean: 
robert_gansel
Contributor III
Contributor III

Count Rows with specific Field-Value

Hi Community,

does anyone have an idea how I solve this in the load script:

NoOfRows WHERE value of column A(only in current line) is value of column B (for the whole table)

Example-Table to load:

A          B          C                   

01          01     01                   

01001     01     01001          

02          02     02                   

03          03     03                   

03001     03     03001          

03002     03     03002           

Result:

A          B          C                    NoOfRows(B)               NoOfRows(C)

01          01     01                    2                                   1

01001     01     01001             0                                   1

02          02     02                    1                                   1

03          03     03                    3                                   1

03001     03     03001             0                                  1

03002     03     03002             0                                  1

Many thanks for any help

Robert

Labels (1)
2 Replies
sathishkumar_go
Partner - Specialist
Partner - Specialist

Hi,

Try this

Test:
LOAD * INLINE [
A , B , C 
01 , 01 , 01 
01001 , 01 , 01001 
02 , 02 , 02 
03 , 03 , 03 
03001 , 03 , 03001 
03002 , 03 , 03002 

]
;

Left JOIN (Test)
load
B as A,
COUNT(B) AS NoOfRows_B
Resident Test Group by B;

Left JOIN (Test)
load
C as A,
COUNT(C) AS NoOfRows_C
Resident Test Group by C;

-Sathish

Gysbert_Wassenaar
Partner - Champion III
Partner - Champion III

Try these expressions:

SubStringCount($(=chr(39) & concat('/' & B & '/' ,'|') & chr(39)) ,'/' & A & '/')

SubStringCount($(=chr(39) & concat('/' & C & '/' ,'|') & chr(39)) ,'/' & A & '/')


talk is cheap, supply exceeds demand