r/excel • u/elephantinaspiderweb • May 27 '24
solved Count "n" number of occurrences and then fill "n" number of cells with data

Hi y'all. Right here I'm showing you two tables; range B2:I6 is my data, while table L2:L8 is what I'm trying to construct with a formula.
Table B2:I6 shows the country of residence of some people, and then proceeds to count the number of people living in that country. Then, I would like for the range in L3:L8 to fill itself with all the countries people live in, with the number of people living in a country determining the number of cells filled with the country's name within that column.
Sadly, I've no idea how to do this, so I any help is appreciated!
•
u/AutoModerator May 27 '24
/u/elephantinaspiderweb - Your post was submitted successfully.
Solution Verifiedto close the thread.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.
4
u/MayukhBhattacharya 1327 May 27 '24 edited May 28 '24
Hi, many ways to resolve this, here are few options, I have outlined:
• Using XLOOKUP()+SCAN()+SEQUENCE()
• Using TEXTSPLIT()+REPT()+CONCAT()
• Using TOCOL()+IF()+SEQUENCE()
• Just another method:
NOTE: You will need to change name of the Table in the formulas given above to suite with the table name you have, also you don't need the output in L3:L8 to be Structured References aka Tables , since all the outputs will spill automatically hence no need to fill down! MS365 Exclusive !!!
• Using POWER QUERY
To use Power Query follow the steps:
NOTE: POWER QUERY is one time operation that is you will not require to change the ranges nor you will need to drag down, although the above formulas doesn't needs to do the same. So, whenever you add new data just refresh the imported table from Power Query. You will see the updated data.
1
u/[deleted] May 27 '24
Are you willing to consider a change to your data structure? Your data table (country counts) should be organized with these three columns:
| Country | Counter (Name) | Count |
You could then add a total row to the data table which would give you the counts you need, and you would filter down to analyze. If you want the analysis table separately, this is also possible with a SUMIFS formula, where you are summing how many times a country appeared.
If you are not willing to consider the change in data model, I think you can use Advanced Filter, Copy To: to transfer data to the 2nd table, but it will be limited by your current layout.
1
u/Decronym May 27 '24 edited May 28 '24
Acronyms, initialisms, abbreviations, contractions, and other phrases which expand to something larger, that I've seen in this thread:
|-------|---------|---| |||
NOTE: Decronym for Reddit is no longer supported, and Decronym has moved to Lemmy; requests for support and new installations should be directed to the Contact address below.
Beep-boop, I am a helper bot. Please do not verify me as a solution.
[Thread #33859 for this sub, first seen 27th May 2024, 23:32] [FAQ] [Full list] ^[Contact] [Source code]
1
u/Simplifkndo 37 May 27 '24
You have the following option to display the countries where people live.
Cell F3 =IF(I3:I6>0;B3:B6;"")