SSRS Multi Column Report Row Visibility - reporting-services

Using the faking multi-column report using tables method here:[https://stackoverflow.com/questions/10882784/ssrs-how-to-continue-data-to-next-column]
I need a report to show multiple columns sorting my data across and then down the page. I need page breaks by Category and the title of each category to repeat on the page.
I have 4 identical tablixes across my page with =IIF((RowNumber(Nothing) Mod 4) = 1, False, True) ect. in the row visibility and a sort on $. The 4 tablixes are wrapped in a list that is grouped by Category with a page break between each group.
Here are my issues if you can help:
If I just have my 4 tablixes across the page with the sort it works fine and sorts properly.
When I try to add the page break and grouping, I get the sort wrong. The page will break by category but if the data in a grouping doesn't end in the 4th column the next page seems to start where the previous page ended. For example, page 1 ends in column 3 so page 2 starts with column 4 instead of 1. How can I adjust this so the next page always starts in the 1st position with the highest $ by category.
If the category goes more that 1 page - I lose the headings.

Update: the OP has explained that their problem is that they aren't using SQL at all, this is a DAX problem. So I will update my (already lengthy) instructions for how to do this, with a followup article that deals with the same problem but using DAX instead of SQL to get the required columns to do this work properly.
For anybody who is just casually interested, the short answer resolution is that this is hard to do with a lot of tweaking of specialized design objects in the RDL, and it's not very extensible that way, because you're going to have to hardcode your individual column-tablixes in the designer. BUT it quite easy to do with a dataset that contains proper column and row index values; you only need ONE tablix and you can dynamically set up the number of columns without a bunch of work. Then you group by the row index and the column index, you're done.
So, in the OP's case, the problem is getting those two index values into the dataset. I found this pretty straightforward -- in fact, doing it allowed me to go back and somewhat simplify the required SQL as well -- EXCEPT :
If the report requires a row grouping to be included in the designer object it's more difficult to get the column and row index values to be appropriate to the group level values that you will need. In SQL, this is just a simple case of adding a PARTITION BY instruction, but there are numerous articles on the web about how to do the same thing in DAX, none of which seemed to work for me -- I'm not a DAX expert, so maybe somebody else will chime in with the right way to do that?
So, for DAX, I start with the same basic technique, I will still use one tablix, but I will add some expressions into the row and column groupings to compensate. Still pretty easy and still completely dynamic, and maybe we could do without the exception if a DAX expert wants to think over the problem. What you're looking for is a row and column assignment that looks like this (assuming 2 cols have been requested, group is needed, items are alphabetically sorted, and you need to go Down-Then-Across):
Group
Item
Row Index
Col Index:
Fruit
Apple
1
1
Fruit
Peach
2
1
Fruit
Pear
3
1
Fruit
Persimmon
1
2
Fruit
Rasberry
2
2
Veg
Carrot
4
1
Veg
Cauliflower
5
1
Veg
Green Bean
4
2
resulting in :
Group
Col 1
Col 2
Fruit
Apple
Persimmon
Peach
Rasberry
Pear
Veg
Carrot
Green Bean
Cauliflower
Or like this, matching the OP's requirement, Across-Then-Down, again assuming 2 cols and alpha sort:
Group
Item
Row Index
Col Index
Fruit
Apple
1
1
Fruit
Peach
1
2
Fruit
Pear
2
1
Fruit
Persimmon
2
2
Fruit
Rasberry
3
1
Veg
Carrot
4
1
Veg
Cauliflower
4
2
Veg
Green Bean
5
1
resulting in:
Group
Col 1
Col 2
Fruit
Apple
Peach
Pear
Persimmon
Rasberry
Veg
Carrot
Cauliflower
Green Bean
Without grouping DAX in either direction will work exactly the same way as the SQL version, and can be swapped as datasets into the same tablix with no other changes, in fact.
The OP also mentioned needing to repeat the headings, which was already anticipated in the original article and continues to work fine.
While this response is lengthy -- in hopes of getting a DAX expert to provide a way that will allow RANKX to give the right grouped index values directly in the dataset -- I'm not being coy by not working out the code details here; that will be longer, deserves to be a blog article.
So here it is: Snaking Columns for I hope the last time ever

Related

How do I select rows that contain any of the selected values in any of the selected columns? MySQL

I'm pretty much trying to get all of the rows that contain any of the relevant tags in any of the relevant columns.
Take a look at an example row:
[LeadID Leadname Ratings AvgRating Address Website Phone TimesOpen Category LeadDescription CurrentStatus]
1 Siena Tuscan Steakhouse 396 4.300 104 S Broadway, Wichita, KS 67202, United States http://www.sienawichita.com/ +1 316-440-5300 LGBTQ+ friendly2022-05-19 Thursday 5PM–12AM
2022-05-20 Friday 6:30–10AM
2022-05-21 Saturday 7–11AM
2022-05-22 Sunday 7–11AM
2022-05-23 Monday 6:30–10AM
2022-05-24 Tuesday 6:30–10AM
2022-05-25 Wednesday 5PM–10AM
restaurants Hotel restaurant-bar offering refined Italian plates & many wines in a warm & elegant atmosphere.
I don't think you'll need to see it in structured form so I apologize for it being messy.
Everything in [ ] are the column names, and the following are its respective fields.
Here is my query
SELECT LeadID
FROM cleancopy
WHERE
Website OR LeadName OR LeadDescription OR Category
IN ('%Event%' OR '%Live%' OR '%Music%' OR '%Venue%');
This query is returning all rows unfiltered.
I want the query to select all rows that contain any number of the relevant tags "Event", "Live", "Music", "Venue", in any of the column names Website, LeadName, LeadDescription, Category.
So one or all of the tags could be in one or all of the attribute types.
More simply put, I'm trying to filter out any row that doesn't contain any of the keywords I want.
First thing: "I don't think you'll need to see it in structured form" is a very bad assumption. We DO need this because it makes it much easier to provide a good answer.
Second thing: This is not the kind of data checking SQL is done for. So there is no simple way especially when you really need a list of strings and a like condition. Such complex data handling should better be avoided or done outside SQL and within the application.
Anyway, the shortest way to do what you describe will be to CONCAT all columns and then search for your strings using OR.
SELECT leadid FROM cleancopy WHERE
CONCAT(website,leadname,leaddescription,category) LIKE '%Event%'
OR CONCAT(website,leadname,leaddescription,category) LIKE '%Live%'
OR CONCAT(website,leadname,leaddescription,category) LIKE '%Music%'
OR CONCAT(website,leadname,leaddescription,category) LIKE '%Venue%'

SSRS filter to show more than one type of entry

I'm sure this is pretty simple, I need an expression that I an use within Group Properties to show only a certain type of product. My Column title is Product_Group within this are fruit and veg. Potatoes, Carrots, peas, Oranges and Apples. I want my filter to work so that when I run my report only apples and oranges appear. I thought this would be as simple as
=(Fields!Product_Group.Value ="apples")and(Fields!Product_Group.Value = "oranges")
Your AND needs to be an OR
=(Fields!Product_Group.Value ="apples")OR(Fields!Product_Group.Value = "oranges")

How can I add titles to columns in a matrix that are created dynamically in a report?

I have a matrix that creates 3 columns when it's run and I am unable to add a title to those dynamically created columns, as required by the client, and can't find any fixes or examples online. I hoped putting the matrix and textboxes into a table might work, but the same result as the images below occurs.
Is this seemingly simple thing just not possible, or is there a workaround I'm missing?
Design View
Result Textbox displayed after columns
Row and Column Groups visible
If you have 3 MTLH1 value for each NTLH2 value then you can do something like this...
(as you supplied no sample data I generated some from the sample WideWorldImporters database). My Query gives me 5 columns and results similar to the below.
CustomerCategoryName Qtr Mnth MnthName OrderValue
Computer Store 1 1 Jan 10
Computer Store 1 2 Feb 12
Computer Store 1 3 Mar 15
Computer Store 2 4 Apr 20
Corporate 1 1 Jan 11
....
Basically we end up with 3 months per quarter
I then added a matrix control to the report, dragged CustomerCategoryName to the rows, Mnth to the Columns , Qtr above Mnth so it becomes a parent column and finally OrderValue to the data "cell".
I actually swapped the Mnth field out for MnthName in the column header to make it easier to read, but the column order is still sorted by Mnth (the numeric version). I then centered the column headers for readability.
The final design looks like this
If we run the report, the result looks like this..
As you can see we have 4 groups, one for each quarter, each with 3 columns.
If you want to customise the quarter names, you could do that if required by changing the expression in the cell. For example if we wanted all quarters to have "Q" preceeding the number except the 2nd Quarter whcih we want to have a specific string then you could use something like.
=IIF(
Fields!Qtr.Value = 2,
"Second Quarter",
"Q" + Cstr(Fields!Qtr.Value)
)
The final output now looks like this...
Alternatively, you could generate all the column headers in t-sql so where I have MnthName you could create a Quartername or similar.
Hopefully this is useful. If not, please post sample data and expected results of that sample data and I'll revise the answer.

Report Builder 3.0 - How to add 2 columns of values both belonging to the same field

Here is the view of table in ''conception'' view:
Conception view
And here's what it gives:
Executed view
As you can see my Column group entitled [Poste_Histo___Etat_Description_Abrégé] breaks out into 3 categories when I run the report: Comblé, Vacant and Vacant_att
I want to blend Vacant and Vacant att into just 1 category and name it Vacant, so to have only 2 categories when the report is being run.
I tried multiple functions and there was one that got me close, but event then, it only renamed Vacant_att to Vacant and didn't add the 2 columns though:
=IIF(InStr(Fields!Poste_Histo___Etat_Description_Abrégé.Value, "Vacant") Or InStr(Fields!Poste_Histo___Etat_Description_Abrégé.Value, "Vacant_att"), "Vacant", "Comblé")
So my goal is to figure this out and ultimately, portray these same values on a graph in the same manner: that is to have only "Vacant" and "Comblé" as categories.
p.s. If it makes any difference, all the «Expr» are the following formula:
=Sum(IIF(InStr(Fields!Poste.Value, ""+"300") Or InStr(Fields!Poste.Value, ""+"100"), 1, 0))
It's point is to only get the values for that end with 300 or 100.
Thanks a lot to any1 who helps!
I ended up finding my answer myself lol. For any1 having eventually the same problem, here is my approach:
1- In the Query Designer pane of my dataset, I created 2 Calculated members:
One being Comblé including the [Comblé] category and the other being Vacant in which I combined [Vacant] and [Vacant_att].
2- I used the formula mentioned in my question as partly successful and replaced the 1 with the newly created calculated members correspondingly. So:
For Vacant:
=Sum(IIF(InStr(Fields!Poste.Value, ""+"300") Or InStr(Fields!Poste.Value, ""+"100"), Fields!Vacant.Value, 0))
For Comblé:
=Sum(IIF(InStr(Fields!Poste.Value, ""+"300") Or InStr(Fields!Poste.Value, ""+"100"), Fields!Comblé.Value, 0))
3- So this gave me the right numbers BUT (as per the pic attached) as long as I had [Poste_Histo___Etat_Description_Abrégé] as a Parent Group in my Tablix, which was no good since this dimension has 3 categories originaly (Vacant, Vacan att. and Comblé) I ended up with 3 columns who have 2 columns each (my newly created Calculated members - Vacant and Comblé)... so 6 columns
Table 1.0
4- Finally to tackle this issue, I created 2 columns both out of the parent group [Poste_Histo___Etat_Description_Abrégé] : Vacant2 and Comblé2. And I simply copy pasted that same formula in these but only to discover that the values were all 3 times larger (sum of the 3 columns). As a simple way out, I just divided each formula by 3 and . As so:
=(Sum(IIF(InStr(Fields!Poste.Value, ""+"300") Or InStr(Fields!Poste.Value, ""+"100"), Fields!Comblé.Value, 0)))/3
And voilà!
p.s. in Table 1.0, Vacant2 and Comblé2 are a percentage of the ratio of each calculated member over the sum of the two.

MySQL Splitting Column Results into Dynamic Columns in View

I'm not sure if this is possible using MySQL alone, or whether PHP or similar would be required. What I am trying to produce is a view that is dependent upon the amount of information that is present in one table to determine how many columns are displayed in the view.
I have a Components table containing the following fields:
CM_ID (The component ID)
CM_CODE (A specific company assigned code)
CM_DESCRIPTION (A brief description of the component)
FORMAT_ID (A referenced FK)
ITEM_ID (A referenced FK)
An example of a select from the Component table is:
CM_ID CM_CODE CM_DESCRIPTION FORMAT_ID ITEM_ID
1 111111 Technical Manual 1 (280 Page A4 Book) 32
2 111112 Schematic Diagram 2 (A3 Fold-out sheet) 32
3 222223 Technical Manual 1 (280 Page A4 Book) 2
4 222224 Price Guide 25 (32 Page A4 Book) 2
5 333335 Instruction Manual 33 (220 Page A5 Book) 44
The view I'm trying to get is based upon displaying items (from the master items table). Each item will have one or many components (which are brought in with an FK on CM_ID)
I have produced the following view:
SELECT i.item AS Item,
GROUP_CONCAT(DISTINCT CONCAT(cm.CM_CODE, _utf8', ',cm.CM_DESCRIPTION, _utf8,', ',f.FORMAT_DESCRIPTION) SEPARATOR '; ') AS Components
FROM item AS i
JOIN components AS cm ON i.ITEM_ID = cm.ITEM_ID
JOIN format AS f ON cm.FORMAT_ID = f.FORMAT_ID
This will obtain results in the form of:
Item Components
2 222223, Technical Manual, 164 Page A4 Book; 222224, Price Guide, 32 Page A4 Book
32 111111, Technical Manual, 280 Page A4 Book; 111112, Schematic Diagram, A3 Fold-out
44 333335, Instruction Manual, 220 Page A5 Book
Only the 2 columns are returned (Item & Components), due to the concatenation. What I'd like to be able to do is to form separate columns for the item's components that are dependent upon the actual amount of components.
Example output:
Item Component1 Component2
2 222223, Technical Manual, 164 Page A4 Book 222224, Price Guide, 32 Page A4 Book
32 111111, Technical Manual, 280 Page A4 Book 111112, Schematic Diagram, A3 Fold-out Sheet
44 333335, Instruction Manual, 220 Page A5 Book
Note that Item 44 only has one component, therefore, it has no data in the component2 column. Should a select be done on JUST item 44, then ideally, there would be no mention of the Component2 column at all. Similarly, if another item came along with 4 components, then the output would automatically scale to form 4 Component columns.
I've looked at a number of ways to acheive this, but none seems to be exactly right. Is this possible?
Many Thanks in advance
Iain
UPDATE **
Ok, I'm trying to set a defined number of columns and do the select on that but still having difficulty. I've added another field to the Components table:
CM_ORDER
Which can be used to differentiate between components for the same item (in theory).
I know this isn't right, but I was trying to get something along the lines of the following to work:
SELECT i.item AS Item,
cm.CM_CODE AS Component_Code1 WHERE cm.CM_ORDER = 1,
cm.CM_DESCRIPTION AS Component_Description1 WHERE cm.CM_ORDER = 1,
cm.CM_CODE AS Component_Code2 WHERE cm.CM_ORDER = 2,
cm.CM_DESCRIPTION AS Component_Description2 WHERE cm.CM_ORDER = 2
FROM item AS i
JOIN components AS cm ON i.ITEM_ID = cm.ITEM_ID
JOIN format AS f ON cm.FORMAT_ID = f.FORMAT_ID
Not sure how I'd get the associated "Format" info in there too. Obviously, MySQL isn't at all happy with me putting multiple WHERE clauses in the SELECT statement so I tried using CASE instead, with as much success (none).
There must be a way to split it out into separate columns in the same query without using a scripting/coding language.
Trying to achieve the result:
Item Component_Code1 Component_Description1 Component_Code2 Component_Description2
2 222223 Technical Manual 222224 Price Guide
32 111111 Technical Manual 111112 Schematic Diagram
44 333335 Instruction Manual
with the associated "Format" data too.
Am hoping that this can be done
Cheers
Iain
Strictly speaking, what you want to do is not possible in SQL. SQL requires that the columns in a query be pre-defined.
One possible approach is to use dynamic SQL for this purpose. You would calculate the maximum number of components in the data, and then use this information to create a query.
You already are trying the second approach, which is to use semi-colon separated lists of comma-separated lists.
The final approach is to settle on some maximum number of components, and build the query for that. So, you could show, say, the first three components.