Conditional cell formatting on SSRS pivot table - sql

I created a pivot table in SQL that has report names along the left side, and hours (00:00, 00:01, etc.) along the top. The values in the table are the number of times each report has been used during that hour over the past three months. I've imported the table into SSRS, and I'm trying to create a heat map of sorts. I want to color the cells darker or lighter across the row based on the number in each cell compared to the value of cells across the row (cell that has the highest value will be the darkest colored).
I've tried following this guide to color the cells, but here the entire row is one field, while I have separate fields for each column. Is there a way to achieve this?
EDIT: Added picture of table design, and preview where coloring is done incorrectly

I understand your problem better now...The function uses the min and max values of a column to determine the range from lightest to darkest, then it probably looks at what fraction of the range your actual value is. In your case where you have each column's data coming from a different cell it'll be a pain unless your columns are fixed and even then it's more trouble than it needs to be.
I would suggest the following.
DON'T PIVOT your data in SQL, we can do that really easily in SSRS, your dataset will be simpler too something like
ReportName Hour UsageCount
ReportA 0 8
ReportA 1 4
ReportC 22 18
and so on...
Create a new report and add a matrix with reportName as the row group and hour as the column group. The data values will be UsageCount.
That's it for the report design, then just set the cells back ground based on your function but this time you can pass in Max(Fields!UsageCount.Value) etc as per the sample.
I've rushed this a bit so it if not clear, let me know and I'll post a clearer solution.

Related

Can we show values from two different timelines in one worksheet in Tableau?

My problem statement is described below :
I have a calculated field, say Opportunity. There is pre defined rule from organization, that the target value for current month will be 1/3rd of the value of 2 months back. For example, The target opportunity value for April will be 1/3rd value of February. I need to show the current month's opportunity and the targeted value in the same worksheet. How to achieve this is Tableau?
I am getting the base data from tables in Oracle through a custom sql query, and calculating the opportunity value in Tableau for each row, and then showing the sum for a range of time , say last 6 months.
The best way to do this would be to write the target value in SQL. It'll be easier (no need for data blending / complex calcs) and also more performant as it would be a hardcoded value in your dataset.

Static Values from Multiple Queries/Datasets in Single SSRS Tablix

ok so I have this report I have to write in SSRS with a very specific format. It looks like the screenshot below at the bottom. Ignore the arrows and colors. It's pulling from an Oracle database. Each number value cell in this table/matrix has a different sql query to pull it in because they come from different tables, etc.
the top half of the numbers in the table are each from a query. the bottom half of the table is all calculations from the numbers in the top half. I already have the queries for the top half and was trying to figure out how I could just use those to make this table in SSRS with just those and then creating calculations in the bottom half for the report. I can't use a table or a matrix because each query is a different dataset and you can only have one dataset per tablix.
I was thinking maybe doing textboxes and drawing the grid manually, which would be a huge pain. I get errors about not having an aggregate and being out of scope or something and haven't figured out the reason for this yet as it is not my ideal solution.
My current solultion that will eventually get me there is unioning every single query and then creating columns with static values for the rows and columns in the grid and turning it into a matrix. Problem with this is it continues to increase in complexity as I create each further down the table calculation, and the code becomes larger and larger, and takes a long time to create, and I have to do like 6 reports similar in nature to the format of this one. Will probably be a thousand lines of sql and force me to have to make a stored proc because of the ssrs character limitation.;
So my question in a more simple way is, how can I take multiple sql queries that return a static value and make them a single value in a tablix that doesn't repeat, then create more blank rows in that tablix that are calculations of other cells values, i.e. Textbox1 - textbox2, textbox3/textbox4 ?
I got it figured out using expressions with multiple datasets. The answer seemed too easy once I found it. Basically just created a table tablix using my first dataset. Created more detail rows with insert row inside group below. Then I went to the expression builder for each one and found the other dataset and double clicked it to get the expression to pull from the other dataset. For example the bac_labor dataset value would look like this. =Sum(Fields!BAC_LABOR.Value, "BAC_Labor")
Then for calculations can use either same thing like =Sum(Fields!BAC_LABOR.Value, "BAC_Labor") + Sum(Fields!BAC_LABOR_OVERHEAD.Value, "BAC_Labor") or could do something like this =ReportItems!Textbox2.Value - ReportItems!Textbox1.Value to reference a cell value. This saves a ton of time, development effort, and reduction of code for calculations, compared to adding together 500 character select statements to make calculations. Also no need to use stored procs and union or join every select statement together with this method.

SSRS Matrix Report : Colors condition

I have a matrix table created with Rows as Days ,Columns as Months and quantity of rainfall as the data field(got all this information from same table 'Rainfall'). I have taken this data from a dataset containing multiple tables in SQL. All of this information displays properly.
Now I have many tables with date field in my dataset in tables other than 'Rainfall'.
In the data field of the matix I need to be able to add my own colors using a Switch case.
The Condition I need is "if a certain date from one table matches the date in my report then i want xxx colour."
eg: there is a table called fertilization which has 3 dates. Now if these 3 dates also exists in my matrix then that block should be colored blue.
Can anyone help me. Thanks!
You can also manage it from sql side while retrieving data from Rainfall table.
You can do this using by right clicking the field that you want the dynamic color on and selecting properties. Select Border and then where it says color hit, click the Fx button. Here you can write a custom expression that will change the background color based upon your code.

Customize the last three rows of a Tablix in SSRS

I have a table which is getting data from a query. Because I am not doing any calculation in SSRS, but instead in SQL and only pulling the data, I am having hard time figuring out how to customize the style for the last three rows.
Here is the design view:
Here is the preview:
Now as you can see the last three rows are either SUM or AVG of the above numbers. How can I make it so that the table displays a different background color for the bottom three rows?
You will need to add an expression for the text box format for the three rows that says something like:
=IIF(Fields![ARRIVED_DATE].Value="WEEKLY TOTAL","Grey",IIF(Fields![ARRIVED_DATE].Value="Prior Week","Red",IIF(Fields![ARRIVED_DATE].Value="12 WEEK AVERAGE","Green","Transparent")))
If i understand your point correctly this would be the solution =iif(total number of records(int)=rownumber(nothing), "Color1",iif(total number of records(int)-1=rownumber(nothing),"Color2",iif(total number of records(int)-2=rownumber(nothing),"Color3",""))) use this expression in Background color of row properties.

Excel: SUMing values that fall in a range (Extending SUMIFS to use ranges of Criteria)

First post - please be gentle.
I have an interesting problem where I'm trying to convert a flat data table into a cumulative total based on two ranges (to create cumulative graphs of progress). Something that should be really easy to do.
I've managed to collate the data into a summary table (effectively a pivot table but for layout and charting purposes I cant use an actual pivot table).
(I'm too new to post images - sorry its not embedded)
Screenshot
In this screenshot I'm trying to show the 3 columns on the left as a Flat data table.
Columns A & B are text values that can be 'any' text (so I cant use wild cards).
Column C is the value I'd like to SUM.
Currently I'm using an SUMIFS statement to find the sum of the "Hours" when the "Week" label matches the values in "column A" and the "Department" label matches the value in "Column B".
I would like to change this equation to find the cumulative value for each week (so in this example cell G6 would be 14 - i.e. 4 from week 1 and 10 from week 2.)
I would like to try and avoid duplicating the entire table just to find the cumulative
All I really need to be able to do in this example is replace the equation in F5:
=SUMIFS($C$2:$C$15,$B$2:$B$15,$E5,$A$2:$A$15,F$4)
with
=SUMIFS($C$2:$C$15,$B$2:$B$15,$E5,$A$2:$A$15,$F$4:F$4)
eg Sum the hours of all the weeks that have come before. Again - i cant use wild cards and I cant use pivot tables.
I imagine I need to use some Array formulae but I cant find any online resources to help me.
Any help would be appreciated.
Your formula works in Cell F5, but in G5 just make it add F5.
F5 =SUMIFS($C:$C,$B:$B,$E5,$A:$A,F$4)
G5 =SUMIFS($C:$C,$B:$B,$E5,$A:$A,G$4)+F5
H5 =SUMIFS($C:$C,$B:$B,$E5,$A:$A,H$4)+G5
I5 =SUMIFS($C:$C,$B:$B,$E5,$A:$A,I$4)+H5
Also use the entire column reference A:A if you dont know the total number of rows.
If you cant do that you could make your read data into a table and then instead of the sum_range being some defined locations, you can use Table1[Week] = Column A instead.
Hope this helps
-Scheballs