4.8 Sort some data by the specified order and the rest by the original order
Below is part of the sales table that records sales data in each province in May, 2022:
YearMonth | Province | Sales |
---|---|---|
202205 | Fujian | 2102086 |
202205 | Hebei | 9044720 |
202205 | Beijing | 3930744 |
202205 | Guangdong | 7731222 |
202205 | Anhui | 4186809 |
202205 | Shanghai | 1799575 |
202205 | Jiangsu | 6497024 |
…… | …… | …… |
The task is to rearrange the table by putting records of Beijing, Shanghai and Guangdong in order at the beginning and the rest of records after them in the original order.
SPL script:
A | |
---|---|
1 | =T(“data.xlsx”) |
2 | =[“Beijing”,“Shanghai”,“Guangdong”] |
3 | =A1.align@s(A2,province) |
Execution result:
YearMonth | Province | Sales |
---|---|---|
202205 | Beijing | 3930744 |
202205 | Shanghai | 1799575 |
202205 | Guangdong | 7731222 |
202205 | Fujian | 2102086 |
202205 | Hebei | 9044720 |
202205 | Anhui | 4186809 |
202205 | Jiangsu | 6497024 |
SPL Official Website 👉 https://www.scudata.com
SPL Feedback and Help 👉 https://www.reddit.com/r/esProcSPL
SPL Learning Material 👉 https://c.scudata.com
SPL Source Code and Package 👉 https://github.com/SPLWare/esProc
Discord 👉 https://discord.gg/cFTcUNs7
Youtube 👉 https://www.youtube.com/@esProc_SPL