SSRS Matrix Report : Colors condition - sql

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.

Related

How to show/add the legend in a dual axis chart?

I have created a dual axis chart where I'm graphing the arrival time and the departure time in the same graph, and showing the sum of the number of records as the rows.
By default Tableau adds the "Measure Names" into each of my columns Marks and I get an automated Legend showing the "Number of Records" in one colour.
However, this is not useful at all...
I want each time variable (eg. arrival time) to show up in a different colour. The only way I have been able to do this is by removing the "Measure Names" pill from the Marks card and then setting each axis to have its own colour. But as soon as I do this, the Legend disappears and now I finally get a nice graph with a line in each colour, but no legend to show what line is assigned to what colour.
Also the Legend option gets disabled when I use this layout.
How can I add the Legend to this?
Please note that the solution in this post doesn't help to answer this question.
You should be able to create 2 calculated fields that basically mimic Number of Records like
SUM([Number of Records])
Once you have 2 calculated fields, you can name them each what you desire. Then you should be able to use measure names and those separate calculated fields on each card of your dual axis.
Many, but not necessarily all, views people want to make with job start/arrival and end/departure records are easier if you reshape the data to have one data record recording each state-change event, tied by a common key.
So if your data has columns for Date, ID, Event, User -- where Event can be either Arrive or Depart -- then most visualizations will be much easier. In this view, each user that has arrived and departed will get 2 records instead of just 1. And customers that have arrived but not yet departed will get 1 record.
You can leave your original data in its original form and create this reshaped view in a Tableau Data Source using either Tableau Prep or the DataSource page in Tableau Desktop. You'll need to use the Union operator. That way you can have another data source that points to the original format if that is useful also.

Conditional cell formatting on SSRS pivot table

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.

SSRS Dynamic Graphs

Does anyone know if it is possible to create a graph(s) at run time based on the dataset?
To clarify, I have a count of patients suffering from a health condition, split by week. I need to make a graph per condition with weeks on the X axis and patient count on the Y. Nice and easy so far.
The problem is that the number of conditions displayed in the dataset will be different depending on the values entered for the start and end dates for the reporting date range.
With this in mind can I create a single graph then tell it to replicate once for each condition returned and only look at the data for that specific condition?
The graphs can't appear in rows as they must aggregate data from multiple rows (where the condition is the same) and plot the various count values over week numbers (the dataset returns a count, a week number and a condition with a group by on the week number and condition)
As an added challenge none of this can be hard coded as the single report has to work across multiple sites.
Thanks
P
Yes this is possible by first dropping a "Matrix" control into the report surface. With the Matrix control, you're able to display groups of data. In this case, your group will be the condition returned in your DataSet. Each group will have an embedded chart which will display data the same way, but only the data within the grouping you choose.
Step 1: Add a Matrix control to your report surface. Create a Row Group based on Condition (In my example, Year)
Step 2: Right Click the empty column on the right side of the Matrix control, and choose the option for Insert Column > Outside Group - Right. Then Delete the middle column.
Step 3: Right click the Right columns "Data" cell (which should be outside the grouping) and choose Insert > Chart. Select the desired chart type.
Step 4: Resize the column and row to view the chart in more detail. Edit the Chart Data to aggregate what you're wanting to show as the line, and pick your category groups.
Step 5: Test, and revist whichever step above needs adjusting.

Qlikview: how to create summary table to filter multiple associated tables

I have 4-5 tables of single and many rows per ID. I want to generate a summary table listing each ID along with various counts and max/mins, but I want to be able to filter on calculations. Example: "ID" is the identifier and there are two tables, TestA and TestB.
One desired selection criteria: Show only those IDs where at least one TestA score >5 and there is at least one TestB score.
In a straight table, this is simple to do with expressions, but the resulting table cannot be selected on the calculated true/false value.
I think I need to create a new table in the load script containing the ID, and then various conditions labeled as I wish. Then, these fields could be dimensions. This seems similar in concept to a master calendar. Am I on the right track?
If it helps to understand my example, this a medical application; the tables are lab results and other interventions that each require complex queries pulling data from various sources that are very "hard-coded" to produce a small data set from millions of rows of highly normalized source data. The desired dimensions would be combinations of the labs so as to allow identification of patients who meet certain criteria--then, once filtered, there would be many more graphs and charts to identify what tests and procedures were followed for that group of patients.
My current data model just loads many tables which then associate on ID. I had attempted to load all data into one big table using concatenates and calculations, but this did not seem to accomplish what I needed and was difficult to manage.
IIUC, I think what you want to do can be accomplished with a combination of sliders/input boxes, variables and calculated dimensions in your table. The process is definitely burdensome, but it should allow you filter the way you want.
Add a field to your table load statement in your script like rnum as RowNo().
Create a variable for your filter(s). Ex. vFilterTestAScore.
Add a slider or input box to your dashboard and point it to that variable.
a. For slider, the option is in the General tab -> Data header -> select the Variable radio button.
b. For input box, add the correct var from the list to the list of Displayed Variables.
Set sliders/input boxes to the criteria you want: vFilterTestAScore = 5 and vFilterTestBScore = 1
Create a straight table with ID as the dimension and expressions for TestAScore and TestBScore. The expression formulas would be sum(TestAScore) and sum(TestBScore) respectively (this won't make sense until the next step).
Now add a calculated dimension to you table. The idea here is that rather than just having the ID dimension, you will create a calculated dimension that only displays the ID of the records that meet the criteria you select in the slider or enter in the input box. The formula should be something like:
if(aggr(sum(TestA), rnum) >= vFilterTestAScore, ID, null()) or for multiple filters: if((aggr(sum(TestA), rnum) >= vFilterTestAScore) and (aggr(sum(TestB), rnum) >= vFilterTestBScore), ID, null()).
On your new calculated dimension, check the 'Suppress When Value is Null' box so only results that meet your criteria are displayed in your table.
To summarize, you are using the variables to store your selection criteria which you are entering via input box or slider. Then you are conditionally displaying only the ID's in your table that match those criteria via a calculated dimension and 'Suppress When Null' option.
I can send you a .qvw if you aren't using the free personal edition and are able to open other qvw's.

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.