melovecookies

New Member
Joined
Sep 7, 2018
Messages
2
How can I get the survey results below shown as second table below? Idea is to capture names of associates who answered "1" in a single cell.

Raw data:

question 1question 2question3
Associate1112
Associate2
<strike></strike>
311
Associate3
222
Associate4
333
Associate5
<strike></strike>
111

<tbody>
</tbody>


Desired end results: (would like to get associates names in a single cell who answered questions as "1"

Question1Associate1, Associate5
Question2Associate1, Associate2, Associate5
Question3Associate1, Associate5

<tbody>
</tbody>

Thanks for your help :)

<colgroup><col><col span="3"></colgroup><tbody>
</tbody>
 

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
if you are able to use PowerQuery (Get&Transform) try

Ascquestion 1question 2question3AttributeAsc.1Asc.2Asc.3
Associate1
1​
1​
2​
question 1Associate1Associate5
Associate2
3​
1​
1​
question 2Associate1Associate2Associate5
Associate3
2​
2​
2​
question3Associate2Associate5
Associate4
3​
3​
3​
Associate5
1​
1​
1​

Code:
[SIZE=1]let
    Source = Excel.CurrentWorkbook(){[Name="Table5"]}[Content],
    #"Unpivoted Other Columns" = Table.UnpivotOtherColumns(Source, {"Asc"}, "Attribute", "Value"),
    #"Filtered Rows" = Table.SelectRows(#"Unpivoted Other Columns", each ([Value] = 1)),
    #"Grouped Rows" = Table.Group(#"Filtered Rows", {"Attribute"}, {{"Count", each _, type table}}),
    #"Added Custom" = Table.AddColumn(#"Grouped Rows", "Asc", each Table.Column([Count],"Asc")),
    #"Extracted Values" = Table.TransformColumns(#"Added Custom", {"Asc", each Text.Combine(List.Transform(_, Text.From), ","), type text}),
    #"Split Column by Delimiter" = Table.SplitColumn(#"Extracted Values", "Asc", Splitter.SplitTextByDelimiter(",", QuoteStyle.Csv), {"Asc.1", "Asc.2", "Asc.3"}),
    #"Removed Columns" = Table.RemoveColumns(#"Split Column by Delimiter",{"Count"})
in
    #"Removed Columns"[/SIZE]

btw. your expected result isn't correct
 
Upvote 0
I am not familiar with powerquery but I will try. Thanks for catching my typo and correcting it. This was my first post and hoping to get better ;)
 
Upvote 0
Hi melovecookies,

This is another approach using VBA assuming your data starts in cell A1

Rich (BB code):
Sub SurveySummary()
Dim Arr() As Variant, AnswerNumber As Integer
AnswerNumber = 1 '<-- Change this to whatever answer number you need
Arr = Application.Transpose(ActiveSheet.Range("A1").CurrentRegion.Value)
For x = 2 To UBound(Arr)
    For y = 2 To UBound(Arr, 2)
        If Arr(x, y) = AnswerNumber Then
            Arr(x, 2) = IIf(IsNumeric(Arr(x, 2)), Arr(1, y), Arr(x, 2) & ", " & Arr(1, y))
        End If
    Next
Next
With Sheets.Add(After:=ActiveSheet)
    .Range("A1").Resize(UBound(Arr), 2).Value = Arr
    .Range("A1:B1") = Array("Question #", "Associates Picked # " & AnswerNumber)
    .Columns("A:B").AutoFit
End With
End Sub
 
Last edited:
Upvote 0

Forum statistics

Threads
1,215,419
Messages
6,124,796
Members
449,189
Latest member
kristinh

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top