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

Announcements
Qlik GA: Multivariate Time Series in Qlik Predict: Get Details
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

How to count days on road with different dimensions

Hi,

please have a look at attached QV doc. I need to be able obtain the number of tripdays by selecting for example two months (see example) and not by using the 'LINK' field.

Available datamodel is one that gives me an ugly solution. I know there should be a much more sofisticated and simple answer to this issue. Please help.













DATA:
LOAD Transport,
Date(Date) as Date,
MonthStart(Date) as CalendarMonthStart,
QuarterStart(Date) as CalendarQuarterStart,
YearStart(Date) as CalendarYearStart,
MonthEnd(Date) as CalendarMonthEnd,
QuarterEnd(Date) as CalendarQuarterEnd,
YearEnd(Date) as CalendarYearEnd,
Month(Date) as Month,
Year(Date) as TRIPYEAR,
Year,
Trip,
Transport&Year&Trip as Link
FROM TRIPLEDGER);

join LOAD Transport&Year&Trip as Link,
Enddate,
Startdate,
num(Floor(Enddate-Startdate)+2) as Tripdays
FROM table is dates);

left join (DATA) INTERVALMATCH (Date)
LOAD DISTINCT Startdate, Enddate
RESIDENT [DATA];

join (DATA) load
Link,
if(year(Enddate)>Year(Startdate), (1+num(Floor(Enddate-CalendarYearStart))),Tripdays) as Tripdays2,
if(Year(Enddate)>=Year(Date), '1', '0') as FLAGTripdays
Resident [DATA];

Thanks in advance,



Sjoerd

1 Solution

Accepted Solutions
johnw
Champion III
Champion III

I don't know quite what you want. Maybe this?

sum(aggr(if(month(Enddate)>month(max(CalendarMonthStart))
,num(floor(CalendarMonthEnd-Startdate)+1), Tripdays2)*FLAGTripdays,Link,Startdate,Enddate))

View solution in original post

3 Replies
Not applicable
Author

Anybody please..

johnw
Champion III
Champion III

I don't know quite what you want. Maybe this?

sum(aggr(if(month(Enddate)>month(max(CalendarMonthStart))
,num(floor(CalendarMonthEnd-Startdate)+1), Tripdays2)*FLAGTripdays,Link,Startdate,Enddate))

Not applicable
Author

Thanks John,

This was excatly what I needed!

Regards