Convert rows to columns in SSIS. Unpivot? - ssis

If I have data like this
"","",WAREHOUSE ID,1,2,3,4,5...
"","",WAREHOUSE CODE,BOS,HOU,LAX,NYC,CHI...
"","",WAREHOUSE NAME,BOSTON,HOUSTON,LOS ANGELES,NEW YORK CITY,CHICAGO...
But want to transform it like this
WAREHOUSE ID, WAREHOUSE CODE, WAREHOUSE NAME
1,BOS,BOSTON
2,HOU,HOUSTON
3,LAX,LOS ANGELES
...
If, as above, [Column 2] is the column that contains what should be the header row, and Columns 3 through 40 contain what should be row values, which columns get selected and set to pass through for the UNPIVOT to perform the desired transposition?
Or is UNPIVOT not even what I'm looking for?

It is technically feasible to solve the problem using one data flow. I posted the basic steps needed to solve the same here. Having said that, its quite a bit of work to configure all the elements in the data flow.

Related

combine 4 rows in to 1 all having unique values

In this image you can see location is combination of different columns. The output i want needs to combine sizes S,M,L,XL to a single row and it should show only one location, Basically s,m,l,xl should be considered one. Also S is supposed to be on level 01,M on level 02, L on Level 03 & XL on 04)
You can use my DJoin function for this, taken from my project VBA.DJoin.
This also includes a demo file, and you'll see an example on how to list sizes:
using a multi-value field:
However, you probably don't have that. Instead, you'll have to create a table with the sizes and a sorting order, for example:
and include that in the query you use as source with DJoin.

How to get total from another tablix column? (SSRS)

Hello awesome people of stackoverflow!
I need help with a simple problem with my SSRS expression.
How could I do this in SSRS?
As you can on the 2nd table below in my excel screenshot.
for each row we divide -BC5...-BC10 to column/row BC4. To get the desired results for table 2 in excel column total 2018 into column/rows BC17 upto BC22.
I've tried referencing my textbox like this
ReportItems!TextBox1.Value / ReportItems!TextBox2.Value.
But got me the wrong values.
Can someone please help.
Thank you!
If those two tables are in the same table/tablix then it should work with the expression that you wrote (try to type it instead of copy paste sometimes that may work).
=(ReportItems!Textbox7.Value /ReportItems!Textbox1.Value) * 100
If they are not in the same Table/Tablix then you should write like the following:
=(Fields!ColumnName1.Value / Fields!ColumnName2.Value) * 100
Format your cells.
There is not enough info to give you an exact answer but you should be able to work it out.
The first thing you need to do is get the context of the aggregations you want to work with. So click on the cell containing the number you want to divide ([Sum(DiscountOERestated)] ). In the row and column groups panel near the bottom on the screen, look at the row group that is highlighted. For this example I'll assume the row group is called grpCategory.
Now we need to do the same for GrossCatalogRestated. However, GrossCatalogRestated in the top tablix does not appear to be an aggregate. I'll assume it should be the total GrossCatalogRestated for the dataset. For this exmaple, we'll say the dataset name is dsMyDataSet. If it's within a row group, just swap the dataset name out with the row group name that it sits in, just like we did for DiscountOERestated .
So you expression would look something like
=SUM(Fields!DiscountOERestated.Value, "grpCategory") / SUM(Fields!GrossCatalogRestated .Value, "myDataSetName")
This will give you a deicmal result, somehting like 0.025 . You then just need to set the format property to say, "p1", so it shows as 2.5%
If this does not work, edit your question to show the expressions in the cells you are working with along with the rowgroup and dataset names.

SAP Web Intelligence - Summary Column Based on Multiple Criteria

I'm new to SAP Web Intelligence and I'm trying to create a report with a summary column based on multiple criteria. Below is my desired output in Excel as an example. I am having trouble coming up with ways to create this summary column (col H)
Link to the example here.
Essentially, I need column H to do the following:
Score = 0
For each cell in Range C:G, if cell isn't empty, get amount of points test is worth based on region the user is in, and add that score to "Score", and show in Column H as a total at the end.
Is this possible in SAP WI? I really really appreciate any help with this (even a push in the right direction).
Thanks!
I believe you're looking for a compounded IF function in a Variable here.
If you're used to using Excel, you will recognise the similar syntax for it:
=IF(TEST;Value if true;Value if false)
You will want to compound that so that you have and IF based on the 'Region' followed by a list of IF statements for each test that add up the points, followed by another list of IF statements for each test based on the other 'Region'
Something like the following should give you the basic start:
=If([Region]="Oceania";If(IsNull([Test #1]);0;1)+If(IsNull([Test #2]);0;1)+IF(...);If(IsNull([Test #1]);0;2)+If(IsNull([Test #2]);0;0.5)+IF(...))
From there you add the relevant test columns into the sums to get the totals for each row.

MYSQL search table, bit fields

I have a table with rows and where one field is a bit-value with 7 digits.
Suppose I have a procedure where I want to select all rows where this bit field equals '0101010', this is easily done by select * where .... and so on.
But: how do I do if I want to allow one/multiple digits of the digits to be either 1 Or 0, i.e I want to get all rows where the bitfield has an entry on the form 1001*1* where the * can be either 1 or 0. So, in this case I would like all entries where the bit field is 1001010, 1001011, 1001110 or 1001111.
select * from TABLE where bit_field in (1001010, 1001011, 1001110, 1001111) would probably work in this example, but if I want to use only the string '1001*1*' as input to the procedure, what then?
.
Any help is very appreciated.
Thanks,
Niklas
Edit: I've tried this: select * from table where field like bit'\\\0'; for getting all entries of the form **0, but that didn't work...
Edit2: It turned out it vas a bit-field, not binary... problem still remain though.
Not a direct answer to your question, per se', but an alternative approach. You mentioned that you didn't want to convert to individual columns because of legacy code. If you do want individual columns and the only thing holding you back is the legacy code, consider the following.
You could add columns for the options and use insert/update triggers to populate them OR you could create a view that splits the bits into separate columns. For new development, you can code to the new columns. Over time, as you modify legacy code you can change it to the new approach. When all the "read" legacy code has been changed, the last step is to change the "write" code to use the new columns rather than the bit column and remove the triggers.
I have a SQL Fiddle demonstrating this here. Note that I only included an insert trigger for brevity.

Reporting services: Join all field on a dataset

In a report, I've a dataset with a filter(based on a MultiValue parameter).
This dataset contains two field: Id and Name.
I need to display somewhere the concatenation of all names:
Name1 / Name2 / Name3
The problem is that the join method works only on array, and then I cannot specify a dataset as value.
I looked in custom code too, but I didn't found anything working.
How should I do this ?
I may be a bit late for this but for anyone that's interested in this, there is a rather easy way of doing this in SSRS:
=Join(LookupSet(1,1,Fields!Name.Value, "DatasetName")," / ")
SSRS-2008 R2 and higher...
1. Using LookupSet
If you're beyond the 2008 version OP has, there exists a good solution:
=Join(LookupSet(1, 1, Fields!Name.Value, "DatasetName"), " / ")
Credit for this answer using the LookupSet solution goes entirely to #urbanhusky's answer.
SSRS-2008 and lower...
I'm keeping this answer though because it aggregates #urbanhusky's solution with the solutions available to poor souls stuck with OP's version of SSRS and below.
In SSRS 2008 there's only three "options" as far as I can see, each with its own downside. The first one's probably the least hackish.
2. Extra parameter
Create an internal parameter (e.g. "NameParameter", see this SO answer or MSDN) with Allow Multiple Values. Set the default value of the parameter to the Name field from your dataset. Then use the function =Join(Parameters!NameParameter.Value, " / ") to show the joined names in a textbox.
This may be your best bet, but if there are a lot of values the parameter may not work very well.
3. Use a List
Create a List and drag/drop the Name field to it. If necessary, group on the Name as well.
The disadvantage here is that (AFAIK) the list can't be made to show horizontally.
4. Use a Matrix
Oh boy, this one's real ugly. Nonetheless, here goes: create a matrix, drag the Name field to the column header, and hide the first column as well as the second row (for displaying the data).
The main disadvantage is that it's a hack (and quite some overkill), plus you'll have to trim the last seperator character manually with an expression.