r/excel•
cnuthead

Transforming data from 1 column into multiple

unsolved

Hi all,

Sorry for the wonky title, I honestly couldn't think of what it should be... haha.

I am in the process of digitising an excel spreadsheet and have a long list of questions and categories in one row.

So the sheet contains a category, then the questions underneath it. then another category, then questions below it and so on. I need to have the category in each row, so when I transform the data into the system I am using, we know what category a question belongs to.

I need to be able to make it as automated as possible, as I am converting hundreds of these sheets haha.

This is the way that I get them:
Questions
Category 1
Question 1
Question 2
Question 3
Question 4
Category 2
Question 5
Question 6
Question 7

And I need to transform them like this:

|Questions|Category| |:-|:-|:-| |Category 1| |Question 1|Category 1| |Question 2|Category 1| |Question 3|Category 1| |Question 4|Category 1| |Category 2| |Question 5|Category 2| |Question 6|Category 2| |Question 7|Category 2|

I need a formula that will know that a category is a category for the right question (whether I add an extra column when I am transforming them or something), I just cannot think of how to do it.

Edit - formatting

Posted Apr 20, 2021, 2:19 AM UTC

2011
Grey_Patagonia_Vest24•

If they’re labeled Category and Question then you can this formula in B2 =IF(ISNUMBER(SEARCH(“Category”,A2)),A2,B1) ... this searches the text to the left for the word Category, if it appears it returns the position of the word in the string - assuming that exists (is a number) then B2 = A2 otherwise B2 = B1 (if it’s a question then set it equal to the category above it.

If it isn’t marked category but all the questions have question marks in them you can use the same function but replace “category” with “?” And then switch the last B1 and A2 with each other

9
GadiyaBhushan•

Can you share a sample data. I have done such re shuffling of data many times.. But i need to know the exact way in which the data is laid out to use my technique

5
Decronym•

Acronyms, initialisms, abbreviations, contractions, and other phrases which expand to something larger, that I've seen in this thread:

|Fewer Letters|More Letters| |-------|---------|---| |IF|Specifies a logical test to perform| |ISBLANK|Returns TRUE if the value is blank| |ISNUMBER|Returns TRUE if the value is a number| |SEARCH|Finds one text value within another (not case-sensitive)|


^(Beep-boop, I am a helper bot. Please do not verify me as a solution.)
^(4 acronyms in this thread; )^(the most compressed thread commented on today)^( has 10 acronyms.)
^([Thread #5711 for this sub, first seen 20th Apr 2021, 03:53]) ^[FAQ] ^([Full list]) ^[Contact] ^([Source code])

2
tartigrad•

As another comment pointed out pivot the column. Just for your information what you want to do is technically known as to change data in wide format to long format

2
AutoModeratorMOD•

u/cnuthead - Your post was submitted successfully.

Please read these reminders and edit to fix your post where necessary:

Failing to follow these steps may result in your post being removed without warning.

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

1
cnutheadOP•

Hi all,

Thanks a lot for answering. I'm not so sure about power pivots, I'm not sure it would do what I want, and I think it would take some time to create, then have to repeat across 150+ sheets. We are talking about a fair bit of data here.

Example Data
https://imgur.com/EVCoT2Z
How I need it
https://imgur.com/rwMAMrs

The number of tasks under each category changes, and the rows the categories are also changes. there is no pattern that I can see to use..

1
Grey_Patagonia_Vest24•

My solution will work for this simply put the formula in C2 = IF(ISNUMBER(SEARCH(“Category”,A2),A2,C1)) . If you don’t want the category rows (Blanks in B2) once you have that you can copy/past Values and filter by blanks in Column B and just delete blank rows.

1
cnutheadOP•

The categories won't always contain the word category though unfortunately :(

1
[deleted]•

[deleted]

1
Grey_Patagonia_Vest24•

Ok but Column B is always blank when there is a category name in A? If so just C2 =IF(ISBLANK(B2),A2,C1)

1
am_iam•

In your original question, you indicate that the data comes in one column. Your image has it in two columns. Is there an item column and is it a number or text? If you do have two columns and the item numbers are not text, you can format as a table. Go to Data>get data from table>transform data You should see that the second column shows null beside the category. Add a conditional column that looks good null, uses the category column else fills it with null. Now you just right click on your new column and fill down. You can rearrange/delete for aesthetics. Duplicate the query for all your other tables.

1