I need to create a heat map data for powerbi. I do not want to do too much filter and formatting on powerbi (yes I could it was deemed not maintainable)
here is my sample data and desired result, smells like pivot to me?
-- product 1_1 1_2 1_3 1_4 1_5
--Oreyos 5 0 0 8 2
declare @heatmap table(product varchar(50), risttitle nvarchar(50), severity int, probability int)
insert into @heatmap
select 'Oreyos', 'not sweet enough', 1, 1 union
select 'Oreyos', 'oki', 1, 1 union
--1_1 there are 2
select 'Oreyos', 'not sweet enough', 1, 2 union
--1_2 there is 1
select 'Oreyos', 'layers 2 thin', 1, 3 union
--1_3 there is 1
select 'Oreyos', 'too crumbly', 1, 4 union
--1_4 there is 1
select 'Oreyos', 'anti milk attitude detected', 1, 5 union
--1_5 there is 1
select 'Oreyos', 'inside out, no good. need crust on outside.', 2, 1 union
select 'Oreyos', 'inside out, no good. need crust on outside.', 2, 1 union
select 'Oreyos', 'inside out, no good. need crust on outside.', 2, 1 union
select 'Oreyos', 'inside out, no good. need crust on outside.', 2, 1 union
select 'Oreyos', 'inside out, no good. need crust on outside.', 2, 1
--2_1 there is 5
/*
heat map is 5 x 5
25 quadrants
in each quandrant count how many items per product for the specific severity and probability
*/
declare @desireheatmap table(product varchar(50), b1_1 int, b1_2 int, b1_3 int, b1_4 int, b1_5 int, b2_1 int)
--1st column severity 1
insert into @desireheatmap(product, b1_1, b1_2, b1_3, b1_4, b1_5)
select 'Oreyos', 2, 1, 1, 1, 1
--2nd column severity 1
insert into @desireheatmap(product, b2_1)
select 'Oreyos', 5
select * from @desireheatmap