Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi,
I'd like to create a line chart with Year-Month as a dimension and the difference between PY and current year sales as a measure, so for example if we have the following dataset:
LOAD * INLINE
[date, year, sales
2019-01, 2019, 150
2019-02, 2019, 200
2019-03, 2019, 550
2018-01, 2018, 200
2018-02, 2018, 400
2018-03, 2018, 300
];
I'd like the chart to display:
2019-01: -50
2019-02: -200
2019-03: 250
Is there a way to achieve this?
Hi,
you could try to solve it inside the script:
TABLE:
LOAD *,
Date(MakeDate(year-1,Right(date,2)),'YYYY-MM') AS date_p,
;
LOAD * INLINE
[date, year, sales
2019-01, 2019, 150
2019-02, 2019, 200
2019-03, 2019, 550
2018-01, 2018, 200
2018-02, 2018, 400
2018-03, 2018, 300
];
Left Join (TABLE)
LOAD
date AS date_p,
sales AS sales_p
Resident TABLE;
After that, you could use this expression:
sum(sales)-sum(sales_p)
sum({<year={'$(=Max(year))'}>}sales)-sum(sales_p) ---> if you want to see only last year