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

Announcements
Qlik and ServiceNow Partner to Bring Trusted Enterprise Context into AI-Powered Workflows. Learn More!
cancel
Showing results for 
Search instead for 
Did you mean: 
JustinDallas
Specialist III
Specialist III

Show InvoiceDetailSum Divided by TravelMiles

Hello Everyone,

So I've got something like the following datamodel (also attached😞

InvoicesAndDeliveries:
LOAD *,
DayStart(Date#(InvoiceDate,'YYYY-DD-MM')) AS 'CalDate'
;
LOAD * Inline
[
InvoiceId, DeliveryOrderId, InvoiceDate,
Invoice1, DelId1, '2019-02-19'
Invoice2, DelId2, '2019-03-24'
]
;

//DeliveryOrder:
Concatenate(InvoicesAndDeliveries)
LOAD *,
Date(DeliveryDate,'YYYY-DD-MM') AS 'CalDate'
;
LOAD * Inline
[
DeliveryOrderId, TravelMiles, DeliveryDate,
DelId1, 1500, '2019-02-16'
DelId2, 3000, '2019-03-23'
]
;

InvoiceDetails:
LOAD * Inline
[
InvoiceDetailId, InvoiceId, DetailCode, DetailAmt
InvoiceDet1, Invoice1, 'LINEHAUL', 665
InvoiceDet2, Invoice1, 'STOPS', 905
InvoiceDet3, Invoice1, 'DELAY', 214
InvoiceDet4, Invoice2, 'LINEHAUL', 766
InvoiceDet5, Invoice2, 'STOPS', 999
]
;

MasterCalendar:
LEFT KEEP(InvoicesAndDeliveries)
Load
DayStart(Floor(Num(TempDate))) AS 'CalDate',
WeekEnd(TempDate) AS WeekEnding,
;
//=== Generate a temp table of dates ===
LOAD
date(mindate + IterNo()) AS TempDate,
mindate,
maxdate // Used in InYearToDate() above, but not kept
WHILE mindate + IterNo() <= maxdate;

//=== Get min/max dates from Field ===/
LOAD
min(FieldValue('CalDate', recno()))-1 as mindate,
max(FieldValue('CalDate', recno())) as maxdate
AUTOGENERATE FieldValueCount('CalDate');

EXIT Script
;

What I want to see is a Barchart with the WeekEnding as it's dimension, and the Sum(DetailAmt)/Sum(TravelMiles) as the measure.

With my live data, I have the Calendar as the dimension, and I have the Sum(DetailAmt)/Sum(TravelMiles) so I get something like this.

QS2.png

QS1.png

 

But once I add the "DetailCode", my data goes away.

QS4.png

QS3.png

The reason I assume that my data is going away is because I'm putting a dimension that comes from a detail table.  And of course, since Orders don't map to the InvoiceDetails, my Sum(TravelMiles) term becomes nonsensical.

 

I've tried. SUM({1}[Order Total Travel Miles]) but that doesn't help either.  I'm at a loss as to what to do.

 

Any help is greatly appreciated.

 

 

0 Replies