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

Announcements
Qlik Connect 2026 Agenda Now Available: Explore Sessions
cancel
Showing results for 
Search instead for 
Did you mean: 
JustinDallas
Specialist III
Specialist III

Show 'Is First Order' in Table

Hello Folks,

I have data that is composed of Orders and Invoices.  The Orders are "children" of the Invoices, and what I'd like to do is mark the first child Order of every Invoice.

My test data looks like so:

Invoice:

LOAD [Invoice Number] AS '%invoice_number',

*

;

LOAD * Inline

[

'Invoice Number', 'Invoice Total'

    'ABC', 300

    'DEF', 400

]

;

Orders:

LOAD * Inline

[

'%invoice_number','Order Number'

    'ABC','1',

    'ABC','2',

    'ABC','3',

    'DEF','8',

    'DEF','9',

    'DEF','10',   

]

;

EXIT Script

;

I'm looking to get something like this.

IsFirstOrder.PNG

The biggest problem I can't get over in my mental model is that I need the row to ignore the current Order Number, yet keep the set analysis restricted to the Invoice Numbe.r

I've tried something the following with no luck.

SUM({<[Order Number]={"=$(Min([Order Number])"}>} [Invoice Total])

Any help is greatly appreciated.

1 Solution

Accepted Solutions
Gysbert_Wassenaar
Partner - Champion III
Partner - Champion III

You can try with an if-statement:

If( [Order Number] = min(total <[%invoice_numer]> [Order Number]), sum([Invoice Total])


talk is cheap, supply exceeds demand

View solution in original post

5 Replies
Gysbert_Wassenaar
Partner - Champion III
Partner - Champion III

If your order data is already sorted you could do something like this:

Orders: 

LOAD *, AutoNumber([OrderNumber], [%invoice_number]) as IndexNumber Inline 

'%invoice_number','Order Number' 

    'ABC','1', 

    'ABC','2', 

    'ABC','3', 

    'DEF','8', 

    'DEF','9', 

    'DEF','10',     

;

Then you can use the new IndexNumber field in the set analysis expression: sum({<IndexNumber={1}>}[Invoice Total])


talk is cheap, supply exceeds demand
JustinDallas
Specialist III
Specialist III
Author

Hello Gysbert,

Unfortunately, the actual datamodel is not as simple as the one I have in my example as there is a join table.  I was hoping to solve this with Set Analysis in my table, and not have to put a one-off calculation in my datamodel if at all possible.

Gysbert_Wassenaar
Partner - Champion III
Partner - Champion III

You can try with an if-statement:

If( [Order Number] = min(total <[%invoice_numer]> [Order Number]), sum([Invoice Total])


talk is cheap, supply exceeds demand
JustinDallas
Specialist III
Specialist III
Author

Thanks Gysbert.  Your solution worked with a little tweaking.  However, I'm curious as to why total <[%invoice_numer] doesn't give the expected result, but total <[Invoice Number]> [Order Number] does. The final solution was:


If( [Order Number] = MIN(TOTAL <[Invoice Number]> [Order Number]), SUM([Invoice Total]))

Gysbert_Wassenaar
Partner - Champion III
Partner - Champion III

Probably because there is no such field as %invoice_number in your data model. That field does exist in the code example you posted, which is why I used it.


talk is cheap, supply exceeds demand