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

Announcements
Join us to spark ideas for how to put the latest capabilities into action. Register here!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Null to Zero in Set Analysis

Hi,

The below expression will return null for some of the rows. I need it to be 0, instead of null. Is there any efficient way of achieving this scenario, instead of using ISNULL function.

=IF(vMas=$(vMat),
SUM(AGGR(ONLY({<A_FLAG={'1'}>+<B_FLAG={'1'}>+<C_FLAG={'1'}>}TRADE), SK, PER)) /
SUM(AGGR(ONLY({<A_FLAG={'1'}>+<B_FLAG={'1'}>+<C_FLAG={'1'}>}VOLUME), SK, PER)))

Thanks

2 Replies
johnw
Champion III
Champion III

You could probably wrap the whole thing in a rangesum() function. The rangesum() function treats any null parameters like they are zero. With one parameter, if it is null, I'd expect it to return 0 like you want.

maneshkhottcpl
Partner - Creator III
Partner - Creator III

Hi,

Please try this if u dont find any way to implement, it will sure work.

= if(

(IF(vMas=$(vMat),
SUM(AGGR(ONLY({<A_FLAG={'1'}>+<B_FLAG={'1'}>+<C_FLAG={'1'}>}TRADE), SK, PER)) /
SUM(AGGR(ONLY({<A_FLAG={'1'}>+<B_FLAG={'1'}>+<C_FLAG={'1'}>}VOLUME), SK, PER)))

)<1,'0',IF(vMas=$(vMat),
SUM(AGGR(ONLY({<A_FLAG={'1'}>+<B_FLAG={'1'}>+<C_FLAG={'1'}>}TRADE), SK, PER)) /
SUM(AGGR(ONLY({<A_FLAG={'1'}>+<B_FLAG={'1'}>+<C_FLAG={'1'}>}VOLUME), SK, PER)))

)