Skip to main content
Announcements
Global Transformation Awards! Applications are now open. Submit Entry
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Errors on Count Key Field

Hi all,

I have the the script

Invoice:           number of rows 413, InvoiceId has distinct values from 1 to 413

LOAD

    CustomerId,

    InvoiceDate as Date,

    InvoiceId;

SQL SELECT *

FROM Invoice;

InvoiceLine:        number of rows 2241, InvoiceId has repeted values   

LOAD InvoiceId,

    InvoiceLineId,

    Quantity,

    TrackId,

    UnitPrice;

SQL SELECT *

FROM InvoiceLine;

I created a text object wjth expression:  =count(InvoiceId) and I had the result 2241.  (I understand why, no problem).

Under InvoiceLine table I inserted the script:

Concatenate (Invoice)

LOAD CustomerId,

     SupportRepId,

     Budget,

     makedate(Year,1,1) as Date

FROM ....

And then the result was 413. I don't understand, I expected was 2241.

Then I have loaded InvoiceLine before Invoice and the the result was 2241.

Why this behavior?

Someone can explain why?

Thanks in advance.

2 Replies
Gysbert_Wassenaar

Don't use count() on a key field. Qlikview won't know which table should be used to count the values. If you want to know the distinct number of InvoiceID values then use count(distinct InvoiceID). That will always return the same result.


talk is cheap, supply exceeds demand
Not applicable
Author

Ok thanks!