Skip to main content
Announcements
Announcing Qlik Talend® Cloud and Qlik Answers™ to accelerate AI adoption! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
danielnevitt
Creator
Creator

Expression help

Hi,

I have the following expression and I would like to include where the hdr_num is DISTINCT.  Is this possible?

Thanks,

Daniel

 

Fabs(sum(if(trade_type_name='APO' and opt_pc_name='Put',(opt_strike_price)*payment_qty, if(trade_type_name='APO' and opt_pc_name='Call',(-opt_strike_price)*payment_qty))))

 

 

 

 

1 Solution

Accepted Solutions
tamilarasu
Champion
Champion

Daniel

You can try below expression,

If(opt_pc_name = 'Put', Sum(Aggr(sum(DISTINCT{<opt_pc_name={`Put`}>}opt_strike_price*payment_qty),hdr_num)),

Sum(Aggr(sum(DISTINCT{<opt_pc_name={`Call`}>}opt_strike_price*-payment_qty),hdr_num)) )

View solution in original post

13 Replies
marinasbc
Partner - Contributor III
Partner - Contributor III

Maybe like

Fabs(sum( {<hdr_num = {"=count(hdr_num)=1"}>}

if(trade_type_name='APO' and opt_pc_name='Put',

     (opt_strike_price)*payment_qty,

     if(trade_type_name='APO' and opt_pc_name='Call',

          (-opt_strike_price)*payment_qty))))

danielnevitt
Creator
Creator
Author

Thanks Marina.

Unfortunately I require distinct rather than a count where it equals 1.

Regards

Daniel

marinasbc
Partner - Contributor III
Partner - Contributor III

{<hdr_num = {"=count(distinct hdr_num)=1"}>} ?

trdandamudi
Master II
Master II

May as below:

Fabs(sum( {<hdr_num = {"=Count(DISTINCT hdr_num)"}>}

if(trade_type_name='APO' and opt_pc_name='Put', (opt_strike_price)*payment_qty,

     if(trade_type_name='APO' and opt_pc_name='Call', (-opt_strike_price)*payment_qty))))

marinasbc
Partner - Contributor III
Partner - Contributor III

No, because the count(...) is just a search string so you can select the hdr_num you want in your set.

So maybe it should be where count distinct equals count:

So maybe {<hdr_num = {"=count(distinct hdr_num)=count(hdr_num)"}>} ?

danielnevitt
Creator
Creator
Author

Thanks for your replies.

I have the below expressions that calculate the value correctly, however I am unsure how to join them together in one field:

Sum(Aggr(sum(DISTINCT{<opt_pc_name={`Put`}>}opt_strike_price*payment_qty),hdr_num)) 

Sum(Aggr(sum(DISTINCT{<opt_pc_name={`Call`}>}opt_strike_price*-payment_qty),hdr_num)) 

Regards,

Daniel

Anil_Babu_Samineni

Like Below,


Sum(Aggr(sum(DISTINCT{<opt_pc_name={`Put` & 'Call'}>}opt_strike_price*payment_qty),hdr_num))

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
danielnevitt
Creator
Creator
Author

Hi Anil,

Thanks for the reply.

The Call is * -payment_qty and the Put is * payment_qty

Regards,

Daniel

Anil_Babu_Samineni

Daniel,

Can you please post sample Application for us?

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful