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

Announcements
Join us in Toronto Sept 9th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
LoKi_asterix
Contributor III
Contributor III

Set Analysis

Hey everyone!

I’m looking to convert a Sum(If) expression into a set analysis format.

Sum(
If(IsNull( %TransCode ) or Len(Trim( %TransCode )) = 0
or
(Len(Trim( %TransCode )) > 0 and (IsNull([Transaction Type]) or Len(Trim([Transaction Type])) = 0)),
$TransAmtLocal
)
)

Labels (2)
1 Solution

Accepted Solutions
BrunPierre
Partner - Master II
Partner - Master II

I get that you want where the transaction code or transaction type is missing, then perhaps

=Sum({1-$<%TransCode = {'*'}> + 1-$<[Transaction Type] = {'*'}>} $TransAmtLocal)

View solution in original post

3 Replies
adilio_silva
Contributor III
Contributor III

I think something like:

{<
  	%TransCode 		= {'*'}
, 	[Transaction Type] 	= {'*'}
>}
Sum($TransAmtLocal)

 

howdash
Creator II
Creator II

What I tend to do in these situations is transfer that IF statement to the script and create a new field in the data model, like this:

tableName:
LOAD *,
    If(IsNull( %TransCode ) or Len(Trim( %TransCode )) = 0 or (Len(Trim( %TransCode )) > 0 and (IsNull([Transaction Type]) or Len(Trim([Transaction Type])) = 0)), 1, 0) as forTransAmtLocal
Resident originalTable
;

Once you have this new forTransAmtLocal field (or whatever you want to call it), your expression can be as simple as this:

Sum({<forTransAmtLocal = {1}>} $TransAmtLocal)

 

BrunPierre
Partner - Master II
Partner - Master II

I get that you want where the transaction code or transaction type is missing, then perhaps

=Sum({1-$<%TransCode = {'*'}> + 1-$<[Transaction Type] = {'*'}>} $TransAmtLocal)