IF statement with Concatenate

shre0047

Board Regular
Joined
Feb 3, 2017
Messages
53
Office Version
  1. 365
Platform
  1. Windows
I'm trying to do a concatenate formula to combine all the categories from sheet 1 into one cell. The values in Sheet1 for categories would be a drop down list of blank, L, M, and H. In Sheet 2, if the category has a value, include it in part of the concatenate formula. Is an loaded IF statement the most efficient way or would a macro make more logical sense?

Sheet1:
IDCategory 1Category 2Category 3Category 4Category 5Category 6Category 7Category 8Category 9Category 10Category 11Category 12Category 13Category 14Category 15
Test1234MHLLM
Testin511MMMLML

<tbody>
</tbody>

Sheet2:
IDCategory Combined
Test1234Area 1: Category 1
Category Value: Medium

Area 2: Category 5
Category Value: High

Area 3: Category 8
Category Value: Low

Area 4: Category 10
Category Value: Low

Area 5: Category 13
Category Value: Medium
Testin511Area 1: Category 1
Category Value: Medium

Area 2: Category 2
Category Value: Medium

Area 3: Category 7
Category Value: Medium

Area 4: Category 9
Category Value: Low

Area 5: Category 11
Category Value: Medium

Area 6: Category 14
Category Value: Low

<tbody>
</tbody>
 

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
simple result with PowerQuery

IDCustom
Test1234Category 01
M
Category 05
H
Category 08
L
Category 10
L
Category 13
M
Testin511Category 01
M
Category 02
M
Category 07
M
Category 09
L
Category 11
M
Category 14
L

Code:
[SIZE=1]let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    #"Unpivoted Other Columns" = Table.UnpivotOtherColumns(Source, {"ID"}, "Attribute", "Value"),
    #"Sorted Rows" = Table.Sort(#"Unpivoted Other Columns",{{"Attribute", Order.Ascending}}),
    #"Merged Columns" = Table.CombineColumns(#"Sorted Rows",{"Attribute", "Value"},Combiner.CombineTextByDelimiter("#", QuoteStyle.None),"Merged"),
    #"Split Column by Delimiter" = Table.ExpandListColumn(Table.TransformColumns(#"Merged Columns", {{"Merged", Splitter.SplitTextByDelimiter("#", QuoteStyle.Csv), let itemType = (type nullable text) meta [Serialized.Text = true] in type {itemType}}}), "Merged"),
    #"Changed Type1" = Table.TransformColumnTypes(#"Split Column by Delimiter",{{"Merged", type text}}),
    #"Grouped Rows" = Table.Group(#"Changed Type1", {"ID"}, {{"Count", each _, type table}}),
    #"Added Custom" = Table.AddColumn(#"Grouped Rows", "Custom", each Table.Column([Count],"Merged")),
    #"Extracted Values" = Table.TransformColumns(#"Added Custom", {"Custom", each Text.Combine(List.Transform(_, Text.From), "#(cr)#(lf)"), type text}),
    #"Removed Columns" = Table.RemoveColumns(#"Extracted Values",{"Count"}),
    #"Sorted Rows1" = Table.Sort(#"Removed Columns",{{"ID", Order.Ascending}, {"Custom", Order.Ascending}})
in
    #"Sorted Rows1"[/SIZE]

the rest is up to you, with Area # and Category Value
 
Upvote 0

Forum statistics

Threads
1,215,035
Messages
6,122,785
Members
449,095
Latest member
m_smith_solihull

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