I have some Data which i want to PIVOT, and i am able to PIVOT it using a Single Column Scenario like below -
Dim FY2019 FY2020 FY2021
NA 20000 30000 25000
EUROPE 10000 15000 20000
ASIA 30000 10000 20000
spark.table("default.sample").groupBy("Dim").pivot("qtr").sum("amount")
Now the challenge am facing is when i am trying to Pivot using 2 or more columns if i want to.
Like i want the data in the below format where the Pivoting should be of 2 Columns.
Dim Country FY2019 FY2020 FY2021
NA US 15000 20000 20000
NA CANADA 5000 10000 5000
EUROPE UK 8000 9000 15000
EUROPE FRANCE 2000 6000 5000
ASIA INDIA 10000 5000 10000
ASIA CHINA 10000 5000 10000
Please help and provide guidance how i can i achieve it using Spark? Thanks in Advance