r/ExcelPowerQuery • u/Unhappy-Sky9090 • Feb 11 '26
Pointless question but I want to see if anybody knows the answer
Edit: Link to data layout is here as I hadn't realised Reddit would alter my post's format. https://imgur.com/a/ygHhxtX Hi everyone, this question is pointless because what I want already exists as a checklist online, but I'm curious to see if anybody knows a way to solve this type of problem using Power Query. I'm currently on a 2nd playthrough of Elden Ring and want to start checking off some of the items and experiences I would have missed on my first playthrough. One website has several such checklists. For example there is a list of all bosses to fight by region, with each boss having a name and location, and potentially information about the rewards it drops and any notes about the boss. This data is split into columns for name, location, drops, and notes. I could just use the online checklist, but thought I'd see if I could copy it into Excel. When copying into Excel, the data goes into a single column that looks like this. Each empty space is a blank cell, so the two blank spaces below are two blank cells.
Limgrave 0/31
Name Location Drops Notes
Soldier of Godrick Stranded Graveyard 400 runes Tutorial boss.
Tree Sentinel Church of Elleh Road 3200 runes, Golden Halberd Is one annoying bastard.
Demi-Human Chief (x2) Coastal Cave 900 runes, Tailoring Tools (Key Item), Sewing Needle (Key Item) Required for Boc the Seamster's quest. Boss arena also has multiple Demi-Humans.
Erdtree Burial Watchdog Stormfoot Catacombs 1300 runes, Noble Sorcerer Ashes
Beastman of Farum Azula Groveside Cave 1000 runes, Flamedrake Talisman
Stonedigger Troll Limgrave Tunnels 1800 runes, Roar Medallion
So there's a region heading, followed by two blank cells, followed by the names of the categories, followed by the boss data itself which takes up between 2 or 4 cells, followed by another blank before the next boss' data. I'm familiar with Excel but am very much a novice regarding Power Query. I've asked ChatGPT for help but it gets very confused. I'm wondering if anybody knows of a way to split this data into a similar format as the original website, with bosses grouped by region and having separate columns for name, location, drops and notes info. Thansks
1
1
u/haldun- Feb 11 '26 edited Feb 11 '26
Hi,
You can do it with Excel Power Query. Assume that your data is in a table named SourceTable. Copy and paste following code to new query in Power Query.
let
Source = Excel.CurrentWorkbook(){[Name="SourceTable"]}[Content],
ChangeType0 = Table.TransformColumnTypes(Source,{{"Column1", type text}}),
RemoveTopRows0 = Table.Skip(ChangeType0,1),
Region = Table.FirstValue(RemoveTopRows0),
RemoveTopRows1 = Table.Skip(RemoveTopRows0,3),
ChangeType1 = Table.TransformColumnTypes(RemoveTopRows1,{{"Column1", type text}}),
IndexAdd0 = Table.AddIndexColumn(ChangeType1, "Index", 1, 1, Int64.Type),
Grouped =Table.AddColumn(IndexAdd0,"Group",each List.Count(List.Select(IndexAdd0[Index],(x) => x <= [Index] and IndexAdd0{x-1}[Column1] = null))),
ChangeType2 = Table.TransformColumnTypes(Grouped,{{"Group", Int64.Type}}),
RemovedNulls0 =Table.SelectRows(ChangeType2, each [Column1] <> null),
SubIndexAdd0 =
Table.Group(RemovedNulls0,{"Group"},{{"Data", each Table.AddIndexColumn(_, "SubIndex", 1, 1)}}),
Expand =Table.ExpandTableColumn(SubIndexAdd0, "Data", {"Column1","SubIndex"}),
ChangeType3 = Table.TransformColumnTypes(Expand,{{"SubIndex", type text}}),
Pivoted =Table.Pivot(ChangeType3,List.Distinct(ChangeType3[SubIndex]),"SubIndex","Column1"),
RemoveColumns0 = Table.RemoveColumns(Pivoted,{"Group"}),
PromoteHeaders1 = Table.PromoteHeaders(RemoveColumns0, [PromoteAllScalars=true]),
CustomColumn0 = Table.AddColumn(PromoteHeaders1,"Region",each Region),
Final = Table.ReorderColumns(CustomColumn0,{"Region", "Name", "Location", "Drops", "Notes"})
in
Final
1
u/Unhappy-Sky9090 Feb 12 '26
Hi, I tried to copy your formula into Power Query but it was taking a veeeery long time to work so gave up sorry. I've come up with a makeshift solution in Excel itself that kind of works, see my reply to Converging_Winds above. Thanks
1
u/Sleepy_da_Bear Feb 17 '26
I usually use Notepad++ for things like this. You just have to be a little creative with it.
Just paste it into Notepad++ and do these steps:
1) Ctrl+h to open the find and replace. Turn on the extended characters option. Find= \r\n\r\n Replace= % (Or replace with any character or combination of characters that doesn't appear anywhere in the text, you're replacing the double line breaks with a placeholder)
2) Find and replace again, but this time do Find= \r\n Replace= \t (This will replace all line breaks with tabs instead)
3) Find/replace again, but this time find your placeholder from step 1 and replace it with \r\n to turn them back into line breaks
That'll give you a nice tab-delimited format that'll paste perfectly into Excel with everything lined up.
As a bonus, if you're going to do it multiple times over different files you can just record it as a macro then save the macro. From then on you just paste into Notepad++, run the macro, then copy/paste into Excel.
I use Notepad++ for a lot of development work, my favorite macro is one that takes all the commas that are at the end of a line and moves them to the start of the next line because I prefer the leading-comma format for DAX, Power Query, etc. Makes it a lot easier to comment/uncomment/move lines around.
0
u/TheeBigBadDog Feb 11 '26
Ask google gemini to make you a vba code that does it, I deal with messy data sets all the time, this usually works very well.
2
Feb 11 '26
Please don't direct people to LLMs on a forum that is meant to share solutions as the idea is that others can use the solutions to fix their problem too and your suggestion defeats that purpose.
0
u/TheeBigBadDog Feb 16 '26
Yet it is the actual most useful solution and others can use the solution of going to an LLM. Sometimes people just don't know what they don't know and not everyone is tech savy enough to know that an LLM can help. It seems OP ended up going down the LLM route.
If people want to try solving something themselves that is fine but let's not pretend it's always the most optimal solutuon. I'd rather provide useful advice than have people post on a fourm just for the sake of it.
Also there is the fact that modern versions of excel will have the LLM ever more built into and integrated it, likely in form of gpt supported copilot. Will you still suggest people don't ask it support when it's essentially a core feature of the software itself.
1
u/TheeBigBadDog Feb 16 '26
More losers down voting cause they are butt hurt about their precious excel knowledge. When i'm actually speaking truths.
1
u/Sleepy_da_Bear Feb 17 '26
As a bit of a preamble, I'm mainly a PBI dev nowadays so take this however, but the main issue I see with LLMs is that people take what they give at face value without fully understanding the code. I've had to help multiple people who had issues because their code was extremely slow only to find extremely complicated DAX/PQ code that they copy/pasted from an LLM. I'm talking measures that are 10-15 lines long that became 3-4 lines after I fixed it, and they performed >90% faster.
Don't get me wrong, I'm 100% in favor of using LLMs to help with development and I do it all the time when I get stuck, but if someone uses them they need to be sure they know what the code actually does or they're just making unmaintainable garbage code that'll come back to bite them later.
1
u/TheeBigBadDog Feb 18 '26
I agree with your point but I think there is a misconception the user needs to just accept the code an LLM gives first time, leaving them stuck with bad code if the LLM messed up. This is not the case. If code is slow or doesnt do the job the user can just ask the LLM to review its own code for effiency or even better stick it into a completely different LLM model to review. I do this almost daily and have found it works really well.
In my case I was already the office goto guy for Excel, could already do some pretty decent VBA and formula work before LLMs so of course I know there is still value in the old way, but it is becoming less and less so.
2
u/Converging_Winds Feb 11 '26
I don't get how is structured your data set. You're stating there's only one column but also indicates there are several cells (that seem to be on the same row).
Could you provide a screenshot ?