Skip to main content
Announcements
Accelerate Your Success: Fuel your data and AI journey with the right services, delivered by our experts. Learn More
cancel
Showing results for 
Search instead for 
Did you mean: 
qv_testing
Specialist II
Specialist II

Compare two fields

Hi Experts,

I have to take ID count and have to compare between String and Compare String (like we have one to many association)

but for example - here I have to take count same in both the fields - so output should be 25

=COUNT(Aggr(COUNT( {<String=P([Compare String])>} DISTINCT ID),ID))  - this expression not giving correct result

70 is taking all the 4 records count, but it should be count for same records.

qv_testing_0-1687268889653.png

I'm expecting below result with out selection compare string

qv_testing_1-1687269060096.png

Note:  only the matching selections should be calculated  between the two fields.

@marcus_sommer@Kushal_Chawda, @MarcoWedel@tresesco  and Experts - can you please take a look 

Thanks in Advance!

Labels (1)
3 Replies
Chanty4u
MVP
MVP

Modify like this 

COUNT( {<String=P([Compare String]), ID={"=Count(DISTINCT String) = Count(DISTINCT [Compare String])"}>} DISTINCT ID)

Kushal_Chawda

@qv_testing  If you have primary Key in table then try below expression.

=count({<Primary_Key= {"=String=[Compare String]"}>}DISTINCT ID)

 

If you don't have primary Key then you can create it using RowNo() function in script

LOAD RowNo() as Key,
    [Compare String],
    ID,
    String
FROM  Data;

then below expression
=count({<Key= {"=String=[Compare String]"}>}DISTINCT ID)

 

If you don't want to create key in script then simply try below expression

=COUNT(distinct if(String=[Compare String],ID))
sidhiq91
Specialist II
Specialist II

@qv_testing  You can try the below expression:

count (distinct  if(string=[Compare String]) ,ID))

Let us know if this has resolved your issue.