Hi @s imam
You can change your dataset like this:
create table tabledemo
([year] int ,
[city] varchar(20),
[zip] varchar(20))
insert into tabledemo
select 2018,'CHI','773'
UNION ALL
SELECT 2018,'VA','703'
UNION ALL
SELECT 2018,'MA','777'
UNION ALL
SELECT 2019,'TX','703'
UNION ALL
SELECT 2019,'NY','703'
UNION ALL
SELECT 2020,'PA','333'
UNION ALL
SELECT 2020,'SA','111'
UNION ALL
SELECT 2020,'HOU','333'
UNION ALL
SELECT 2020,'WA','111'
with cte as(SELECT * , groupby = ROW_NUMBER()over(partition by [year] order by (select 1)) FROM tabledemo)
select * from cte
unpivot
([value] for [type] in([city],[zip]))up
the result :
report design:
preview:
then you can delete the groupby column like this:
final preview:
Best Regards,
Isabella
If the answer is the right solution, please click "Accept Answer" and upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.