Pie chart Series Label Overlapping in SSRS

Issue:

SSRS Pie charts tend to overlap the names when too many small slices are next to each other.

Solution:

A good solution is to sort the pie chart slices between big and small pieces. The following script will reorder your slices. Just insert the name and value into this script and call it from your dataset.

/*This query Alternates min and max values
Insert your ItemCD and values and Join it at the end
Created By William Mendoza*/
/*TEST SAMPLE DATA AREA*/
Declare @ValueTest Table (ID int identity (1,1)
					,Item Varchar(20)
					,Value Decimal(19,6))
INSERT INTO @ValueTest
Values	('ItemA','10.990000'),
		('ItemB','5.000000'),
		('ItemC','15.200000'),
		('ItemD','13.300000'),
		('ItemE','9.000000'),
		('ItemF','20.000000'),
		('ItemG','2.000000'),
		('ItemH','1')
Select * from @ValueTest
/*End TEST*/
/*Implementation Area*/
Declare @NewOrder table(ID int identity(1,1), 
						Item varchar(20),
						Value decimal(19,6),
						[Order] int)

Insert Into @NewOrder(Item, Value)
/***********************Your Query Here; Item ans Value*****************************/
Select Item,value from @ValueTest order by Value asc
/*******************************************************************/
--Select * from @NewOrder

Declare @total int=(Select COUNT(*) from @NewOrder)
Declare @runner int=1
Declare @minus int=0

while (@runner <= @total)
Begin
	IF(@runner % 2)=1
	Begin
		Update @NewOrder
		Set [order]= @runner
		Where ID= 1 + @minus
		Set @minus +=1
	END
	Else
	Begin
		Update @NewOrder
		Set [order]= @runner
		where ID=@total - (@minus - 1)
	End

Set @runner +=1
End
/* JOIN TO NewOrder Table and Order by [Order]*/
Select * from @NewOrder order by [Order]

Related Posts

No Comments Yet.

Leave a reply

You must be logged in to post a comment.