Search code examples
reporting-servicesssrs-2008

Is there a way to display multiple colors in a data bar?


I have a tablix which has a data bar in it that I would like to have displayed in different colors. Is there a way to do this without the need to use an IIF or Switch function?

The reason why I ask is because I do not have anything that I can use for a condition. Below is my query in sql to give you an idea of what I'm working with:

DECLARE @DTempStart DATETIME, @DTempEnd DATETIME

SET @DTempStart = DATEADD(MONTH, DATEDIFF(MONTH, 0, @DateFrom)-3, 0)
SET @DTempEnd = DATEADD(MONTH, DATEDIFF(MONTH, -1, @DateFrom)-1, -1)

SELECT
    DATEPART(year, DateDue) AS YearNum,
    DATEPART(month, DateDue) AS MonthNum,
    DATENAME(month, DateDue) AS 'MonthName',
    COUNT(SiteAudit.SiteAuditID) AS 'Total'
FROM 
    SiteAudit
WHERE
    DateDue BETWEEN @DTempStart AND @DTempEnd AND
    Active = 1 AND
    IsComplete = 1
GROUP BY
    DATEPART(year, DateDue),
    DATEPART(month, DateDue),
    DATENAME(month, DateDue)
ORDER BY
    YearNum,
    MonthNum

If anyone could please help I would much appreciate it.


Solution

  • I don't think there is a way without IIF, Switch or Choose, but you can use any field as a condition. You mention you might need a row number but in that case the row number will be given by an order on fields that can be returned by your query, so why not use those fields directly? In any case, if you want row number you always have the RowNumber function on ssrs:

    RowNumber("DataSetName")