Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi All
I have data as below
Year Qtr | Sales |
2016 q 1 | 11 |
2016 q 2 | 12 |
2016 q 3 | 13 |
2016 q 4 | 14 |
2017 q 1 | 15 |
2017 q 2 | 16 |
2017 q 3 | 17 |
2017 q 4 | 18 |
2018 q 1 | 19 |
2018 q 2 | 20 |
2018 q 3 | 21 |
2018 q 4 | 22 |
I have to show previous year same quarter data in pivot.
desired output
Year Qtr | Sales | Pre Sales |
2016 q 1 | 11 | |
2016 q 2 | 12 | |
2016 q 3 | 13 | |
2016 q 4 | 14 | |
2017 q 1 | 15 | 11 |
2017 q 2 | 16 | 12 |
2017 q 3 | 17 | 13 |
2017 q 4 | 18 | 14 |
2018 q 1 | 19 | 15 |
2018 q 2 | 20 | 16 |
2018 q 3 | 21 | 17 |
2018 q 4 | 22 | 18 |
please help.
Try this
Table:
LOAD *,
Left([Year Qtr], 4) as Year,
Mid([Year Qtr], Index([Year Qtr], ' ') + 1) as Qtr;
LOAD * INLINE [
Year Qtr, Sales
2016 q 1, 11
2016 q 2, 12
2016 q 3, 13
2016 q 4, 14
2017 q 1, 15
2017 q 2, 16
2017 q 3, 17
2017 q 4, 18
2018 q 1, 19
2018 q 2, 20
2018 q 3, 21
2018 q 4, 22
];
FinalTable:
LOAD *,
If(Qtr = Previous(Qtr), Peek('Sales')) as [Pre Sales]
Resident Table
Order By Qtr, Year;
DROP Table Table;
Thanks for your response.
But by any chance can we do it in front end?
What is your expression for Sales? Is it just Sum(Sales)? Also, do you have a only Quarter field in your app?
No. Quarter is my secondary dimension. I have one more dimension. Primary dimension is in rows while secondary is in column.