Skip to main content
Announcements
Accelerate Your Success: Fuel your data and AI journey with the right services, delivered by our experts. Learn More
cancel
Showing results for 
Search instead for 
Did you mean: 
Goncalo
Contributor III
Contributor III

Move Current AGGR dimension to Data Load Editor

Hi Everyone,

I have a dimension that checks if there is at least one invoice item with a PO number. If there is one, then all invoice items are flagged as Yes. 

The formula used is the following (this is a dimension because I may need to filter the Yes or No transactions).

Field: Invoice with PO

=if(isnull(Aggr(count ({<[PO Number]={"=Len([PO Number])>1"}>}total <[Invoice Number]> [PO Number]), [Invoice Number])),'No','Yes')

Now I need to consider the result of the Invoice with PO field and combine with other variables. The intended logic is the following:

  • If Invoice with PO is equal to 'Yes', I need to check if the PO number field is different than '-'. If it is, then the result should be 'Yes', if not, then it should be 'No'
  • If Invoice with PO is equal to 'No', then it is always 'Yes'.

I leave below an illustration of the expected outcome.

Qlik.png

I would also like to have this new column as a Dimension. I tried to combine the formula above with the additional logic but the performance decreased significantly.

I was thinking of moving the Invoice with PO  in to the Data Load Editor so that I could use if to create additional dimensions, but I was not able to create it. Both fields are from the table 'Facts'.

Could you please help me with this? Also, if you have a different way of creating this using dimensions it is also fine, I was just not able to do it.

Thanks.

Labels (2)
1 Solution

Accepted Solutions
justISO
Specialist
Specialist

Hi, it depends on your data model structure, but how I would do, if there are only one table with 3 columns, 'Invoice Number', 'Invoice Item', 'PO number':

DATA_temp:
load * inline [
Invoice Number, Invoice Item, PO Number
1001,1001.01,2001
1001,1001.02,-
1001,1001.03,-
1002,1002.01,2002
1003,1002.01,-
];

InvoiceWpo:
LOAD
[Invoice Number],
count([PO Number]) as hasPoNo
RESIDENT DATA_temp
WHERE len([PO Number])>1
GROUP BY [Invoice Number];

LEFT JOIN (DATA_temp)
LOAD *
RESIDENT InvoiceWpo;

MAIN:
LOAD
[Invoice Number],
[Invoice Item],
[PO Number],
if(hasPoNo>0, 'Yes','No') as [Invoice with PO],
if((hasPoNo>0 and [PO Number]<>'-') or (isnull(hasPoNo)), 'Yes', 'No') as [Valid Invoice Item]
RESIDENT DATA_temp;

DROP TABLES DATA_temp, InvoiceWpo;

View solution in original post

2 Replies
justISO
Specialist
Specialist

Hi, it depends on your data model structure, but how I would do, if there are only one table with 3 columns, 'Invoice Number', 'Invoice Item', 'PO number':

DATA_temp:
load * inline [
Invoice Number, Invoice Item, PO Number
1001,1001.01,2001
1001,1001.02,-
1001,1001.03,-
1002,1002.01,2002
1003,1002.01,-
];

InvoiceWpo:
LOAD
[Invoice Number],
count([PO Number]) as hasPoNo
RESIDENT DATA_temp
WHERE len([PO Number])>1
GROUP BY [Invoice Number];

LEFT JOIN (DATA_temp)
LOAD *
RESIDENT InvoiceWpo;

MAIN:
LOAD
[Invoice Number],
[Invoice Item],
[PO Number],
if(hasPoNo>0, 'Yes','No') as [Invoice with PO],
if((hasPoNo>0 and [PO Number]<>'-') or (isnull(hasPoNo)), 'Yes', 'No') as [Valid Invoice Item]
RESIDENT DATA_temp;

DROP TABLES DATA_temp, InvoiceWpo;
Goncalo
Contributor III
Contributor III
Author

Hello,

Thank you for the quick and insightful reply! I did some adaptation to my data but it worked as expected!

Many thanks, marked as the solution.