Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
mapratt82
Creator
Creator

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!

4 Replies
sunny_talwar

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

Capture.PNG

mapratt82
Creator
Creator
Author

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!

sunny_talwar

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

Attached_Account_Number

Attached_Account_Type

mapratt82
Creator
Creator
Author

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