Skip to main content
Announcements
See what Drew Clarke has to say about the Qlik Talend Cloud launch! READ THE BLOG
cancel
Showing results for 
Search instead for 
Did you mean: 
jduluc12
Creator
Creator

Set analysis question

Hi,

I got this data set

Cust      product           Amount

A              Prod_1          10

A              Prod_2          20

B              Prod_1          20

C              Prod_1          30

C              Prod_3            10

I need to write an expression where it sums the amount for only that customer which has only Prod_1.

For Example

It should consider only Cust B because both A and C have others product too .

Thanks,

11 Replies
vishsaggi
Champion III
Champion III

What is your expected output? You want to see only B cust in your table?

jduluc12
Creator
Creator
Author

Yes that is right

its_anandrjs

In expression write

=count({<Cust={"=count(distinct product)=1"}>}Distinct Amount)

its_anandrjs

Sorry this is right one try

=Sum({<Cust={"=count(distinct product)=1"}>}Distinct Amount)

OP8.PNG

its_anandrjs

Or even this is right one

=Sum({<Cust={"=count(distinct product)=1"}>} Amount)

Dear Jean do you have confusion on the output that shown to you let me know about this.

antoniotiman
Master III
Master III

Hi Jean,

may be this

Sum({<Cust=E({<product-={Prod_1}>})>} Amount)

Regards,

Antonio

its_anandrjs

Another way is you can achieve the same in the script part by find out the frequency of the product count.

Source:

LOAD * INLINE [

    Cust, product, Amount

    A, Prod_1, 10

    A, Prod_2, 20

    B, Prod_1, 20

    C, Prod_1, 30

    C, Prod_3, 10

];

ProdFrq:

Left Join

LOAD

Cust,

Count(product) as CountProd

Resident Source

Group By Cust;

NoConcatenate

LOAD * Resident Source Where CountProd = 1;

DROP Table Source;

jduluc12
Creator
Creator
Author

It is not working

its_anandrjs

Can you share some sample for this or can you check my sample on top on that it is working.