Merge all the data in the second column for each unique value in the first column - merge

I have two columns of data. Some of the data in the first column repeats (they represent questions). The data in the second column is unique (they represent multiple answers to the same question).
I need to merge all the data in the second column for each unique value in the first column. e.g.:
Q,A
1,yes.
1,is possible.
2,no.
2,not possible.
2,cannot do this.
2,impossible.
3,maybe.
merged to:
Q,A
1,yes.is possible.
2,no.not possible.cannot do this.impossible.
3,maybe.

Something like this is crude but may be adequate:
=IF(A1=A2,C1&B2,B2)
copied down to suit. Then select the last entry (identifiable with something like =A1=A2 copied down to suit) for each Question number.

Questions in column A sorted in order
Answers in column B
In C1 use =B1
In C2 use =if(a2=A1,C1&B2,B2)
Drag down formula in C2.
It will keep adding the lines together as long as the question remains the same. When it gets to a new question, it'll start a new string. The last time each question is listed will be the complete string in column C.

Create a 2 column project in Google Refine
Sort by Q column (if not already sorted) and make sort permanent
Blank Down on Q column to remove duplicate values
On A column, do Edit Cells -> Merge multi-valued cells

Related

Cloud Dataprep - Multiply rows in one column based on values in other column

I am working in Cloud Dataprep and i have a case like this:
Basically I need to create new rows in column 2 based on how many rows there is with matching data in column 1.
Is it possible and how?
I understand that the scenario you want to have is: obtain all values from column1 that match a value present in column2. There are many things to consider in this scenario, which you did not describe, such as: can values in column2 be repeated? or if there is a value in column2 missing in column1, what should happen? or what happens the other way around?
However, as a general approach to this issue, I would do the following flow:
With a flow such as this one, you take the input table, which as two columns like this:
In recipes FIRST_COLUMN and SECOND_COLUMN you split both columns into different branches, and do the necessary steps to clean each column. In column1, I understand nothing is needed to be done. In column2, I understand that you will have to remove duplicates (again, this is my guessing, but it would depend on your specific implementation, which you have not completely described) and delete empty values. You can do that applying the following transforms:
Finally, you can join both columns together. Depending on your needs (only values present in both columns should appear, only values present in columnX should appear, etc.) you should apply a different JOIN strategy. You should use a Join key like column1 = column2 (as in the image), and if you choose only the second column in the left-side menu, you will have a single-column result.
Note that in this case I used an Inner-join, but using other JOIN types will provide completely different results. Use the one that fits your requirements better.

Transpose columns in another sheet to rows via Data > Validity dropdown

I have a collection of addresses on one LibreOffice Calc sheet (7 columns, 1st name, 2nd street and so one) and want to create an invoice template on another sheet.
I know how to retrieve and transpose a known row - the solution on this other question explains that: Transpose column on one sheet to row on another, with linking
However, this does not seem to work if I use Data > Validity to fill the first cell in the address area (7 cells below each other).
What I am basically trying to accomplish is a dropdown in the first cell where I select the name and it automatically retrieves the address from the other sheet into the cells below.
Is this possible or am I overthinking here?
I suggest:
Name the data in your first column (eg CName)
Name your array of data (eg Clients)
Set the Source for Validity Criteria to CName
Assuming the validation is in A1, in A2 and copied down to suit:
=VLOOKUP(A$1,Clients,ROW()-0,0)
The -0 is not required if the validation is in Row1 but is where an offset should be made if not.

C1FlexGrid : Check Merged Cell/Dynamic Merging

I have a Grid in which some rows are being merged on the basis of common identifier which is column one i have to do following things but i cant do it anyway to achieve it
I want to see if the first column is merged then second merged row should have a different color like in the preceding columns after 3rd column but its not being happening
I have to merge the preceding columns (5,6,7,8,10,14) on the basis of first column but like its merging the first column its not merging the preceding columns due to its common values like +4.50 is being merged for 2nd and 3rd and 4th record but it should only merged for its own record but due to the same value its merging all three records value
Kindly, help as i am badly stuck in this
i have
Please understand that the style applied to a cell range is decided by the style in the topmost/leftmost row/column. This is why in a single cell range we cannot have multiple styles.
Note: Please refer your comments and reply

Is it possible to create a row that spans all columns of a Matrix in SSRS 2008?

Is it possible to have add a row to an SSRS 2008 Matrix that spans all of the matrix's columns?
This crude diagram shows roughly what I'm looking for:
The basic idea is that each line item is a person, and each column is a field in a form for that person. The fields themselves are dynamic (and implemented as column groups on the matrix). Additional column groups are included to append non-dynamic form fields, like the time the record was entered and who entered it. Under each person's record is a comments field, which should span all of the form fields above it.
At the moment I have the matrix embedded in another tablix, with the name and fields in the matrix and the comments in the parent tablix. This works for the data (each instance of the matrix ends up being one row), but the header repeats too often (once per person) because it's attached to the matrix. The only thought I have as to how to fix this is to create another matrix in the parent tablix with the same grouping and use it to display the headers... But this will require quite a lot of manual synchronization to keep the two matrices the same.
Edit: The key problem here is making the second row span multiple column groups.
Here's what you can do:
Select the column grouping you want to add above and right click and select
Add Group... Parent Group...
Group the column by something that will not aggregate the data. You'll have to select a field from your dataset to group by so that it creates an overlapping column grouping.
Check the Add group header box
You should now see something similar to this:
Now you just need to move the Value1 field and it's header over under the new column to the right beyond the matrix dividers. Once that's done, simply delete the ungrouped column where you just copied Value1 from and be sure to select Delete columns only checkbox.
Your finished product should look like this:
It is possible - And the above answers are partial answers leaving out one key step: Merging the cells of the child row.
First, right click on your grouped row, then select Insert Row -> Inside Group - Below and you will get two rows with the cells aligning on the columns
Second, ctrl click all the cells in your new row (ie row without the data) then right click on one of the highlighted cells, and then select Merge Cells.
Now you have the table you like. To add a value to the new row: first right click your new (multi column) cell,select Create Placeholder, and then add the dataset item you desire to the placeholder.
[Edit]
After several attempts, I'm going to say this isn't possible in SSRS. The best I could come up with is a group footer that spans columns 1,2, and 3, but not the User column.
[Original Response]
I recently did something similar to this.
First, what tool are you using to create SSRS reports? (I used SQL Server Business Intelligence Development Studio)
You'll want to create a row group (grouped on Person)
Append a row to your table in "Design" view (Right click, "Insert Row --> Inside Group - Below").
Add an expression to the row that pulls the value for your "Comment" column (=Fields!Comment.Value).
Let me know if that helps...
Try adding in you column group "header" with a grouping expression of (1=1). Then a detail field will need to be defined. If you define the other group with correct data then the "header" will stretch across all details columns. You may need to merger depending on other options.
The easiest way to do this is to create a Tablix with only one column, and your row grouping.
Then, you create two rows inside this group.
In the first row inside the group, you insert a Matrix, wich you can then subgroup as you prefer.
I just had a similar problem, and this was my solution.
I banged my head against the wall for a lot of time, until i realized the solution to my problem wasn't "making a cell span multiple column groups", but "making a cell split into multiple column groups".
You can accomplish the goal by using a subreport for each person. The subreport will receive the employee id and create the hierarchy for you. Make sure your subreport column widths match the widths of the parent report.

Retrieving value from previous row in calculated column based on condition

I am working on data in Spotfire. The table has 4 columns:
RowID
StudID
IMT
Date
I am trying to insert a calculated column in Spotfire to get the date from the previous row for a specific StudID. The date should not be filled for first entry for a specific StudID since it does not have a previous row.
Please refer to the image for details:
This will be a calculated column using the OVER function, along with Intersect, Previous and the First aggregation.
First([Date]) OVER Intersect(Previous([Date]), [StudID])
It reads: over the intersection between (group of) the previous (to the current row) dates (which are the same) and the Student ID's (the same as the current row), give me the first row of that group. In your example, it will only ever return one date for that group, but the formula needs to be able to handle what happens if there are multiple rows. You may also need to think about whether this will happen in your data and what you're going to do about it. I.e.
StudID Date
124-639 6/12/2018
124-639 6/12/2018
124-639 6/14/2018
Building off of JasonJ's answer, it looks like his solution ran into issues when the dates of different StudIDs overlapped with one another.
So I was seeing something along the lines of this:
StudID, Date, Result
A, 10/1/2014,
A, 10/10/2014, 10/1/2014
A, 10/17/2014, 10/10/2014
B, 10/20/2014,
A, 10/21/2014,
B, 10/22/2014,
B, 10/24/2014, 10/22/2014
I created a weird workaround by adding another Calculated Column.
I doubt this is the IDEAL way to do this (I'd bet there's a better OVER function, but I couldn't identify it right off), but it looks like it's working.
First Calculated Column (Named [CalcRank]):
Rank(Concatenate([StudID],Year([Date]),If(DayOfYear([Date])<10,"0",""),If(DayOfYear([Date])<100,"0",""),DayOfYear([Date])))
Second Calculated Column:
Max([Date]) OVER (Intersect(Previous([CalcRank]),[StudID]))
Please note, you may have to pad your StudID with 0s to make sure it orders properly, like I did with the Date column.