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

Announcements
See why IDC MarketScape names Qlik a 2025 Leader! Read more
cancel
Showing results for 
Search instead for 
Did you mean: 
jduenyas
Specialist
Specialist

A challenge

Hi all

I have a pivot table which shows customer's name, Order number, Invoice number, Shipment Tracking number and Order Total.

DuplicateTotal.JPG.jpg

There are times that an order is too large to physically fit in one box so it ships with 2 boxes each gets its own Tracking Number.

The Total of the order though should appear only once and not as shown as the Grand Total is skewed.

The Expression for the total is

=Sum(Amount)

I can correct that with the following expression

=Sum(Aggr(DISTINCT Amount, OrderNumber)

However, that drops one of the lines and only one Tracking number then appears like this:

DuplicateTotal2.JPG.jpg

But I need to see both Tracking numbers.

How can I achieve that.

Thanks

Josh

1 Solution

Accepted Solutions
Not applicable

Hey Josh,

The reason you see only one tracking number when you use the second formula is because the value would be null() because of your aggregation of OrderNumber. There is nothing unique to aggregate OrderNumber for the second Tracking#.

Try unpressing null() and zero values. It will look like this:

Order#Tracking#Amount
123454589823$6,500
123452345898-

Assume this is a straight table. Similarly applies for Pivot as well.

Hope it helps. These will usually occur because of the way the Data Model is designed.

View solution in original post

4 Replies
chiru_thota
Specialist
Specialist

I guess you can try below idea at Data model:

You can remove tracking number from fact

And create one more table just with OrderNO,Tracking NO.

For TrackingNO column Concatenate values if you have more .Then you will get only one row for each order NO

Example:

OrderNO         ,TrackingNO

0000100488    ,797560638262

0000100779 ,529456752584-529456752595

Nicole-Smith

I'm thinking something with FirstSortedValue()...

Maybe:

FirstSortedValue(aggr(sum(Amount),OrderNumber),OrderNumber)

EDIT: You may need a NODISTINCT in there too

FirstSortedValue(aggr(NODISTINCT sum(Amount),OrderNumber),OrderNumber)

Not applicable

Hey Josh,

The reason you see only one tracking number when you use the second formula is because the value would be null() because of your aggregation of OrderNumber. There is nothing unique to aggregate OrderNumber for the second Tracking#.

Try unpressing null() and zero values. It will look like this:

Order#Tracking#Amount
123454589823$6,500
123452345898-

Assume this is a straight table. Similarly applies for Pivot as well.

Hope it helps. These will usually occur because of the way the Data Model is designed.

jduenyas
Specialist
Specialist
Author

Thank you!

You are a genius!

That worked.