SSRS Column Grouping Based on Row and Column - tsql

I've looked everywhere but found no luck and did some tinkering which didn't amount to much. I have a table that displays the following result set:
| Name | Value|
| Pat | 1.6 |
| Pat | 1.4 |
I have to group them in together by Row based on the first column (which is not a problem). Although I'm trying to make the report put the two numeric values in one cell in the Tablix.
This is what I need to do:
And this is what I have achieved
I achieved the third one by grouping it by the first column of my result set as a Row group.
Any nudge to the right direction will be very much appreciated!

Add a new tablix and add Name field in the Row Groups Pane, then delete details group.
In the Value cell use the below expression:
=join(LookupSet(
Fields!Name.Value,
Fields!Name.Value,
Fields!Value.Value,
"DataSetName"
),Environment.NewLine)
Replace DataSetName by the actual name of yours. You will get:
UPDATE: Expression to surround the second value with parenthesis.
=join(LookupSet(
Fields!Name.Value,
Fields!Name.Value,
Fields!Value.Value,
"DataSet4"
),Environment.NewLine & "(") & ")"
Let me know if this helps.

Related

Crystal Report - Label Printing with a varied page counter

So, our branches are wanting shipping labels created which I have created a template on Crystal reports.
Our issue is using the NofM function. If the user prints one label it will say 1of1 which is correct. We want it so the counter is determined by the number of prints they require for example:
If the user prints 4 pages it will be 1of4 to 4of4.
Any assistance would be appreciated
In Field Explorer, expand 'Special Fields'.
Use the 'Page N of M' special field.
It sounds like you need a solution to duplicate the printing copies based on a parameter.
Option 1. if the max expected quantity is not too large, you can create multiple sections (Details a, Details b, Details c, ...) and use a dynamic suppress condition to hide the sections beyond the quantity parameter.
Option 2. Create a "REPEATER" table with a single column (How_Many) and rows for 1 | 2 | 3 | 4 | 5 | 6 | ...
Now, in your report, add the REPEATER Table and add a Record Selection condition of
{?QTY} >= {Repeater.How_Many}

Overlapping classifications

I'm trying to create classifications based on date that are overlapped between each other.
Taking "Sample - EU SuperStore" as a reference, I want to do the the following:
Show measures as rows, for example Sum of Profit and sum of Sales
Create two columns: 2016 and Q1 2016.
Output Example:
+-------------+---------+---------+
| Measures | 2016 | Q1 2016 |
+-------------+---------+---------+
| sum(Profit) | 49,544 | 3,811 |
| sum(Sales) | 484,247 | 74,448 |
+-------------+---------+---------+
Is there a way to achieve this without changing the underlying data model?
I've tried using parameters but at the moment of putting to parameters together they are consider as the same column with different "hierarchies". See image below (Parameters are called 1 and 2)
If your periods of interest only overlap because one of them is a total of some of the others, you may be able to just use turn on the totals and sub totals of interest from the menu.
Otherwise, you can define calculated fields that select your values of interest for some records, and null for other records. Some people call those conditional fields or conditional calculations. Since aggregation functions like SUM(), MAX() ignore null values, you can then use those fields as measures to get the effect you want.
For instance, if you create a calculated field called [Sales During Promotion] as
If [Date] >= #2/15/2020# and [Date] <= #3/15/2020# then [Sales] end
Then SUM([Sales During Promotion]) will be the sum of all sales that fell within the specified period.
The last trick to understand the calculated field above is to know that the default behavior if there is no else branch specified is to return null.

Tableau Crosstab Row Percentage of Whole

I am new to Tableau and I have created a crosstab that shows a count of items per type. I want to add a column to my table. I need to know the percentage of the whole - I looked up a couple of things but I can't seem to find this exact problem.
Type |Count |% of Whole
-----------------------------------
A |10 |1%
B |99 |9.9%
C |256 |25.6%
D |300 |30%
E |335 |33.5%
After reading some I think my issue is that I am not sure how to derive a calculation that is going to give a TOTAL # of Types. In Excel I would take the row value divided by the sum of all rows. Additionally I am fairly certain that this will lead to an issue once I filter this table - not sure I know how to preserve the percentages with filters.
I am using Tableau 9.2. Thanks in advance for any help.
You can create the following calculated field:
SUM([Count])/TOTAL(SUM([Count]))
TOTAL takes into consideration all values of your variable.
Alternatively, you can use quick table calculation by right-clicking on count (here I'm using an example from the Superstore dataset):

SSRS Matrix Grouping Vertically to keep headers in same column? Is it not possible?

using SSRS 2008 R2 here.
I've been able to get a similar layout to work with a regular tablix, where I get each group header to fall on top of each other in the same column by adding a row within that group, however I need to use a Matrix because of a dynamic column (month below). When I try to add another row, it only adds a row where the monthly data starts, not in the headers. So the headers stay in their each column. In trying to keep the example as easy as possible, I'm trying to do something like this (Store theme).
STORE NAME | MONTHS
STATE | SALES
TOWN(S) | SALES
which woudl look something like this in a Matrix
WALMART JAN FEB MARCH etc....
TEXAS | 3000 2000 6000
HOUSTON | 1000 500 2500
AUSTIN | 2000 1500 3500
I've only been able to produce something like this where each group is a seperate column:
STORE | STATE | CITY | JAN | FEB | MAR |
WALMART | TEXAS | HOUSTON | 1000 | 500 | 2500 |
| AUSTIN | 2000 | 1500 | 3500 |
Again, I've been able to get a regular Tablix formatted like this, but a Matrix I'm struggling with. Can anyone help me on how to do this? Thank you in advance!!
It is possible using a tablix/matrix and adding some special grouping settings.
Add a tablix with the City field in Row Groups pane:
Right click the City group, select Add Group / Parent Group. Choose State and set Add a Group Header
Delete the left most column (State column added in the previous step).
Note the group is still present.
Right click the STATE group and add a Parent Group as step 2. In this case choose STORENAME
Again delete the left most column (Store Name column added in the previous step)
You will get the following tablix.
Delete the first row
Set the Fields using the Row Group hierarchy order. STORENAME/STATE/CITY
Right click the first cell in the next column and add a group / Column Group / Parent Group. Choose MONTH in group by.
Delete the first row.
Set SUM(Fields!Sales.Value) in the next cells in the same column.
After these steps you will get a tablix like this in design window.
It should produce:
Let me know if this helps.

Tableau to calculate occurrence of row variable

Trying to figure out tableau calculated fields:
I would like to calculate the occurrence of a row variable. Example:
Fruit | Occurrence
Apple | 2
Apple | 2
Orange | 1
Banana | 1
Occurrence should be the calculated field which in Excel would be =COUNTIF([fruit]=[#fruit])
What's the equivalent syntax for Tableau?
Just take in consideration that if you use "FIXED" the filters won`t wot
I suggest to use "INCLUDE"
{INCLUDE[Fruit] : COUNT([Fruit])}
My solution works with WINDOW calculations. Also, it requires data disaggregation: Tableau online documentation
Code for discrete Calculation2 (Compute using PANE DOWN):
RUNNING_COUNT(ATTR([Fruit]))
Code for discrete Calculation3 (Compute using PANE DOWN):
WINDOW_MAX([Calculation2])
Whether or not this still works when you shuffle around the values in the data source, I do not know. You would need sorting for the Fruit column then, I guess.
I've realised the right answer is:
{FIXED [Fruit] : COUNT([Fruit])}
Where fixed creates a set array filtering the all rows containing the current row's same variable.