Qlik Community

New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

mapratt82
New Contributor III

Invalid Expression Help

Here is the part I am getting the error on:

Attached:

LOAD "Card_Number",

    "Attached_Account_Type",

    "Attached_Account_Number";

SQL SELECT "Card_Number",

    "Attached_Account_Type",

    "Attached_Account_Number"

FROM XXXXXXXXXXXXXXXXXX;

Attached2:

Load "Card_Number",

if(count(distinct if(Attached_Account_Type=1,Attached_Account_Number))=2 and Max(Attached_Account_Number)=Attached_Account_Number, Attached_Account_Number,

    if(Attached_Account_Type=1,Attached_Account_Number)) as "Checking 1",

    if(count(distinct if(Attached_Account_Type=2,Attached_Account_Number))=2 and Max(Attached_Account_Number)=Attached_Account_Number, Attached_Account_Number,

    if(Attached_Account_Type=2,Attached_Account_Number)) as "Savings 1",

    if(count(distinct if(Attached_Account_Type=1,Attached_Account_Number))=2, Min(Attached_Account_Number)) as "Checking 2",

    if(count(distinct if(Attached_Account_Type=2,Attached_Account_Number))=2, Min(Attached_Account_Number)) as "Savings 2"

Resident [Attached]

Group by [Card_Number];

Drop Table [Attached];

Basically I could have up to 2 checking and/or 2 savings tied to a single card and would like to separate out into Checking 1&2 and Savings 1&2. Help please!

Tags (2)
4 Replies
MVP
MVP

Re: Invalid Expression Help

I think the problem is the unaggregated Attached_Account_Number field in your Attached2 table

Capture.PNG

mapratt82
New Contributor III

Re: Invalid Expression Help

That doesn't seem to help. I'm still getting the error. I also tried adding the adding Attached_Account_Type, which made a little more sense, but it didn't help either. Thanks!

MVP
MVP

Re: Invalid Expression Help

Sorry,  I thought they were the same fields, but there are two unaggregated fields

Attached_Account_Number

Attached_Account_Type

mapratt82
New Contributor III

Re: Invalid Expression Help

I ended up taking another approach and was able to achieve the desired results. Thanks for the help, though.