Hi, We have an order table which has two years order, like the below.
Order Table Original:
SalesID
FrozenDate
ORValue
1001
2022/10/1
100
1001
2022/10/1
50
1001
2022/11/3
30
1001
2022/11/10
70
1002
2022/09/30
200
1002
2022/08/04
40
1005
2021/04/05
0
I created a master calendar table . The script is as below.We need calculate YTD . So I create YTD calendar and concatenate with the master calendar. Master Calendar field 'FrozenDate' could mapping order table to calculate P1 to P12 and YTD order value.
Master Calendar Script:
Master_Calendar_Temp: LOAD Date(TempDate) as "FROZENDATE", 'P'&Month(AddMonths (Date(TempDate,'MM/dd/yyyy'),3))*1 as Month, if (date(TempDate)>='10/1/2022', 'CY','PY') as FY; LOAD $(vMinDate) + IterNo() - 1 as TempDate Autogenerate 1 While ($(vMinDate) + IterNo() - 1) <= $(vMaxDate);
Concatenate
load Date(TempDate) as "FROZENDATE", 'CY' as FY, 'YTD' as Month; LOAD $(vMinDate) + IterNo() - 1 as TempDate Autogenerate 1 While ($(vMinDate) + IterNo() - 1) <= Today()-1;
Concatenate
load Date(TempDate) as "FROZENDATE", 'PY' as FY, 'YTD' as Month; LOAD $(vMinDate) + IterNo() - 1 as TempDate Autogenerate 1 While ($(vMinDate) + IterNo() - 1) <= AddYears( date(num(Today())-1),-1);
But In our business scope, when we select 'YTD' and customer A who doesn't have any order until now , but it need show 0 in the screenshot chart .In others words , all the customer have to map P1 to P12 and YTD. If the customer doesn't have order in any period, just 0. It' so difficult. How to solve it?