Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
i want to create a master calendar that isn't linked to any orderdate or any other table
Let me explain it a bit better as i have been quite ambiguous...
Data sample
name | datefrom | dateto | duration |
john | 21/12/2015 | 24/12/2015 | 4 |
john | 27/01/2016 | 27/01/2016 | 1 |
john | 12/02/2016 | 15/02/2016 | 2 |
john | 26/02/2016 | 26/02/2016 | 1 |
john | 10/03/2016 | 10/03/2016 | 0.5 |
john | 01/04/2016 | 01/04/2016 | 1 |
john | 18/04/2016 | 18/04/2016 | 0.5 |
john | 29/04/2016 | 29/04/2016 | 1 |
john | 02/09/2016 | 09/09/2016 | 6 |
Current (pivot table) output:
Current pivot table dimensions:
name
tempdate
Current pivot table expression:
IF(tempdate >= datefrom AND tempdate <= dateto, 1, 0 )
Expected output (shortened) i would like ALL dates shown not just the populated ones:
name | tempdate | 19/12/2015 | 20/12/2015 | 21/12/2015 | 22/12/2015 | 23/12/2015 | 24/12/2015 | 25/12/2015 | 26/12/2015 | 27/12/2015 | 28/12/2015 | 29/12/2015 | 30/12/2015 | 31/12/2015 |
john | 0 | 0 | 1 | 1 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
ALSO tempdate comes from the master calendar example on here....
QuartersMap:
MAPPING LOAD
rowno() as Month,
'Q' & Ceil (rowno()/3) as Quarter
AUTOGENERATE (12);
Temp:
Load
min(datefrom) as minDate,
max(dateto) as maxDate
Resident newtable;
Let varMinDate = Num(Peek('minDate', 0, 'Temp'));
Let varMaxDate = Num(Peek('maxDate', 0, 'Temp'));
DROP Table Temp;
TempCalendar:
LOAD
$(varMinDate) + Iterno()-1 As Num,
Date($(varMinDate) + IterNo() - 1) as TempDate
AutoGenerate 1 While $(varMinDate) + IterNo() -1 <= $(varMaxDate);
MasterCalendar:
Load
TempDate AS datefrom,
TempDate AS tempdate,
week(TempDate) As Week,
Year(TempDate) As Year,
Month(TempDate) As Month,
Day(TempDate) As Day,
YeartoDate(TempDate)*-1 as CurYTDFlag,
YeartoDate(TempDate,-1)*-1 as LastYTDFlag,
inyear(TempDate, Monthstart($(varMaxDate)),-1) as RC12,
date(monthstart(TempDate), 'MMM-YYYY') as MonthYear,
ApplyMap('QuartersMap', month(TempDate), Null()) as Quarter,
Week(weekstart(TempDate)) & '-' & WeekYear(TempDate) as WeekYear,
WeekDay(TempDate) as WeekDay
Resident TempCalendar
Order By TempDate ASC;
Drop Table TempCalendar;
Script:
Table1:
LOAD * INLINE [
enum, datefrom, dateto, duration
12, 21/12/2015, 24/12/2015, 4
12, 27/01/2016, 27/01/2016, 1
12, 12/02/2016, 15/02/2016, 2
12, 26/02/2016, 26/02/2016, 1
13, 10/03/2016, 10/03/2016, 0.5
13, 01/04/2016, 01/04/2016, 1
13, 18/04/2016, 18/04/2016, 0.5
13, 29/04/2016, 29/04/2016, 1
13, 02/09/2016, 09/09/2016, 6
];
Table2:
LOAD * INLINE [
enum, name
12, john
13, rahul
];
QuartersMap:
MAPPING LOAD
rowno() as Month,
'Q' & Ceil (rowno()/3) as Quarter
AUTOGENERATE (12);
Temp:
Load min(datefrom) as minDate,
max(dateto) as maxDate
Resident Table1;
Let varMinDate = Num(Peek('minDate', 0, 'Temp'));
Let varMaxDate = Num(Peek('maxDate', 0, 'Temp'));
DROP Table Temp;
TempCalendar:
LOAD $(varMinDate) + Iterno()-1 As Num,
Date($(varMinDate) + IterNo() - 1) as TempDate
AutoGenerate 1
While $(varMinDate) + IterNo() -1 <= $(varMaxDate);
MasterCalendar:
Load TempDate AS Date,
week(TempDate) As Week,
Year(TempDate) As Year,
Month(TempDate) As Month,
Day(TempDate) As Day,
YeartoDate(TempDate)*-1 as CurYTDFlag,
YeartoDate(TempDate,-1)*-1 as LastYTDFlag,
inyear(TempDate, Monthstart($(varMaxDate)),-1) as RC12,
date(monthstart(TempDate), 'MMM-YYYY') as MonthYear,
ApplyMap('QuartersMap', month(TempDate), Null()) as Quarter,
Week(weekstart(TempDate)) & '-' & WeekYear(TempDate) as WeekYear,
WeekDay(TempDate) as WeekDay
Resident TempCalendar
Order By TempDate ASC;
Drop Table TempCalendar;
Join(MasterCalendar)
LOAD DISTINCT enum
Resident Table1;
FinalMasterCalendar:
LOAD *,
Date&enum as Key
Resident MasterCalendar;
DROP Table MasterCalendar;
Join(Table1)
IntervalMatch(Date, enum)
LOAD datefrom,
dateto,
enum
Resident Table1;
Dimensions:
name
Date
Expression:
RangeSum(
Count({<Key = {"=Len(Trim(datefrom)) > 0"}>}DISTINCT name),
Avg({<Key = {"=Len(Trim(datefrom)) = 0"}>}0))
No selections
john selected
Rahul selected:
And in case you want the total to show the total number of days, you can try this:
Sum(Aggr(RangeSum(
Count({<Key = {"=Len(Trim(datefrom)) > 0"}>}DISTINCT name),
Avg({<Key = {"=Len(Trim(datefrom)) = 0"}>}0)), name, Date))
I hope this resolve all the issues
Absolutely perfect sunny!!!
Amazing!!
I am glad we were able to finally get this resolved.
Best,
Sunny
UPDATE: I guess you already did the helpful response part
Just so I understand, is this the alternative to the bar chart where you wanted to show the date ranges in the same row? I think you are probably going to use colors instead of 1's right?
just a quick one.
for the one that allows a total:
Sum(Aggr(RangeSum(
Count({<Key = {"=Len(Trim(datefrom)) > 0"}>}DISTINCT name),
Avg({<Key = {"=Len(Trim(datefrom)) = 0"}>}0)), name, Date))
can this be done so it isnt affected by any selections EXCEPT fieldY
May be this:
Sum({<fieldY>}Aggr(RangeSum(
Count({<Key = {"=Len(Trim(datefrom)) > 0"}, fieldY>}DISTINCT name),
Avg({<Key = {"=Len(Trim(datefrom)) = 0"}, fieldY>}0)), name, Date))
Yeh the bar (gant) chart thing just wasnt working so adding colours to this does the same job, and processes a lot quicker
Very nice, I really like how you approached this problem. I must confess that I did not think of doing this, but this will help me think of alternatives at other occasions now.
Thanks for teaching me a new thing
Best,
Sunny
sorry i wasnt clear enough, i meant a way so that only the total bit isnt affected paart from with fieldY
May be like this:
If(SecondaryDimensionality() = 0,
Sum({<fieldY>}Aggr(RangeSum(
Count({<Key = {"=Len(Trim(datefrom)) > 0"}, fieldY>}DISTINCT name),
Avg({<Key = {"=Len(Trim(datefrom)) = 0"}, fieldY>}0)), name, Date)),
RangeSum(
Count({<Key = {"=Len(Trim(datefrom)) > 0"}>}DISTINCT name),
Avg({<Key = {"=Len(Trim(datefrom)) = 0"}>}0)))