Create a Heat Map Legend

Create a new Straight Table

You must create a new Straight Table to hold the data for the legend. In the Straight Table, create a Calculated Dimension. The Calculated Dimension should reference the image files in our load script and mimic the logic of our heat map, similar to the following:

=	if(count(DISTINCT TOTAL Zip) = 1, RGB(28,75,27),
    		if(aggr(Sum(Receipts),Zip) <= fractile(TOTAL aggr(Sum(Receipts),Zip), 0.1), 1,
    		if(aggr(Sum(Receipts),Zip) <= fractile(TOTAL aggr(Sum(Receipts),Zip), 0.2), 2,	
    		if(aggr(Sum(Receipts),Zip) <= fractile(TOTAL aggr(Sum(Receipts),Zip), 0.3), 3,	
    		if(aggr(Sum(Receipts),Zip) <= fractile(TOTAL aggr(Sum(Receipts),Zip), 0.4), 4,
    		if(aggr(Sum(Receipts),Zip) <= fractile(TOTAL aggr(Sum(Receipts),Zip), 0.5), 5,
    		if(aggr(Sum(Receipts),Zip) <= fractile(TOTAL aggr(Sum(Receipts),Zip), 0.6), 6,
    		if(aggr(Sum(Receipts),Zip) <= fractile(TOTAL aggr(Sum(Receipts),Zip), 0.7), 7,
    		if(aggr(Sum(Receipts),Zip) <= fractile(TOTAL aggr(Sum(Receipts),Zip), 0.8), 8,
    		if(aggr(Sum(Receipts),Zip) <= fractile(TOTAL aggr(Sum(Receipts),Zip), 0.9), 9,	
    		if(aggr(Sum(Receipts),Zip) <= fractile(TOTAL aggr(Sum(Receipts),Zip), 1.0), 10
    		))))))))))) 

Change the Background Color and Text Color

Now that the calculated dimension creates the appropriate buckets, next you must change the “background color” and “text color” for the calculated dimension to create the appropriate shading.  Click the “+” next to the new calculated dimension to expose these properties.

Both the “background color” and “text color” fields should look similar to the following:

=	if(count(DISTINCT TOTAL Zip) > 1,
    		if(min(aggr(Sum(Receipts),Zip)) <= fractile(TOTAL aggr(Sum(Receipts),Zip), 0.1), RGB(247,252,197),
    		if(min(aggr(Sum(Receipts),Zip)) <= fractile(TOTAL aggr(Sum(Receipts),Zip), 0.2), RGB(222,232,178),
    		if(min(aggr(Sum(Receipts),Zip)) <= fractile(TOTAL aggr(Sum(Receipts),Zip), 0.3), RGB(198,212,159),
    		if(min(aggr(Sum(Receipts),Zip)) <= fractile(TOTAL aggr(Sum(Receipts),Zip), 0.4), RGB(174,193,140),
    		if(min(aggr(Sum(Receipts),Zip)) <= fractile(TOTAL aggr(Sum(Receipts),Zip), 0.5), RGB(149,173,121),
    		if(min(aggr(Sum(Receipts),Zip)) <= fractile(TOTAL aggr(Sum(Receipts),Zip), 0.6), RGB(125,153,102),
    		if(min(aggr(Sum(Receipts),Zip)) <= fractile(TOTAL aggr(Sum(Receipts),Zip), 0.7), RGB(101,134,83),
    		if(min(aggr(Sum(Receipts),Zip)) <= fractile(TOTAL aggr(Sum(Receipts),Zip), 0.8), RGB(76,114,64),
    		if(min(aggr(Sum(Receipts),Zip)) <= fractile(TOTAL aggr(Sum(Receipts),Zip), 0.9), RGB(52,94,45),
    		if(min(aggr(Sum(Receipts),Zip)) <= fractile(TOTAL aggr(Sum(Receipts),Zip), 1.0), RGB(28,75,27)
    		))))))))))) 

Create the proper expressions

Create 3 expressions that look similar to this:

min(aggr(sum(Sales),Zip))
• '-'
max(aggr(sum(Sales),Zip))

Finalize ordering, sizes, and sorting

Finalize ordering, sizes, and sorting

Once this is done, change the column ordering, column sizes, and sorting appropriately so it looks similar to the above.