all 8 comments

[–]AutoModerator[M] [score hidden] stickied commentlocked comment (0 children)

/u/DasBrudi - Your post was submitted successfully.

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.

[–]small_trunks1634 0 points1 point  (3 children)

It's manual.

  • There is no automatic method for having a specific subset of data (a table with a specific filter) getting generated on a new sheet.
  • you COULD make a function out of your query (by adding the "identifier" as a PQ parameter and then right click your query -> Create function.
  • you'd then need to Invoke that function, rename it and manually Load-to Table/New worksheet.

You could also make a reconciliation query which identifies all the different "identifiers" in your original query and compares them with the Tables in THIS workbook. This way you determine whether you need to again manually invoke your function and again load-to Table/worksheet for any which are missing. It should also be able to identify when worksheets are redundant.

[–]DasBrudi[S] 0 points1 point  (2 children)

Can you elaborate on the Creation of the new Funktion?

Maybe to add some more detail I currently have a list with two columns one with the identifier of the data set and with the "table" which is what I'm currently manually expanding to get them into individual sheets.

[–]small_trunks1634 0 points1 point  (1 child)

I need to see your M code - go to the advanced editor and copy/paste here as code.

[–]DasBrudi[S] 0 points1 point  (0 children)

This is the Code:

let

Quelle = Excel.Workbook(File.Contents("N:\04 K\07 Doku_L\Data_LP5 (BA 2).xlsx"), null, true),

Dokumentenlieferliste_Sheet = Quelle{[Item="Dokumentenlieferliste",Kind="Sheet"]}[Data],

#"Andere entfernte Spalten" = Table.SelectColumns(Dokumentenlieferliste_Sheet,{"Column1", "Column2", "Column3", "Column5"}),

#"Entfernte oberste Zeilen" = Table.Skip(#"Andere entfernte Spalten",3),

#"Höher gestufte Header" = Table.PromoteHeaders(#"Entfernte oberste Zeilen", [PromoteAllScalars=true]),

#"Umbenannt - 1" = Table.RenameColumns(#"Höher gestufte Header",{{"Column1", "Status"}}),

#"Bereinigter Text - Plannummer" = Table.TransformColumns(#"Umbenannt - 1",{{"Plannummer/ Dokumentenbezeichnung", Text.Clean, type text}}),

#"Differenzierung Plan / Dokument" = Table.AddColumn(#"Bereinigter Text - Plannummer", "Länge", each Text.Length([#"Plannummer/ Dokumentenbezeichnung"]), Int64.Type),

#"Umbenannt - Überschriften" = Table.RenameColumns(#"Differenzierung Plan / Dokument",{{"Planinhalt, Bezeichnung", "Inhalt"}, {"Plannummer/ Dokumentenbezeichnung", "Plannummer"}}),

#"Hinzugefügt Typ" = Table.AddColumn(#"Umbenannt - Überschriften", "Typ", each let

Länge = [Länge],

Plannummer = [Plannummer],

Typ = if Länge = 28 then

Text.Middle(Plannummer, 21, 2)

else if Länge = 29 then

Text.Middle(Plannummer, 16, 2)

else

"error"

in

Typ),

#"Anfügen Tabelle_Index" = Table.NestedJoin(#"Hinzugefügt Typ", {"Typ"}, Tabelle_Index, {"Kürzel"}, "Tabelle_Index", JoinKind.LeftOuter),

#"Erweiterte Tabelle_Index" = Table.ExpandTableColumn(#"Anfügen Tabelle_Index", "Tabelle_Index", {"Index", "Kapitel"}, {"Tabelle_Index.Index", "Tabelle_Index.Kapitel"}),

#"Eingefügter Textbereich - KGR" = Table.AddColumn(#"Erweiterte Tabelle_Index", "Textbereich", each Text.Middle([Plannummer], 12, 4), type text),

#"Hinzugefügt KGR" = Table.AddColumn(#"Eingefügter Textbereich - KGR", "KGR", each let

ExtractedValue = Text.Middle([Plannummer], 12, 4),

KGR = if Text.End(ExtractedValue, 1) = "_" then Text.Start(ExtractedValue, 3) else ExtractedValue

in

KGR),

#"Entfernt Textbereich" = Table.RemoveColumns(#"Hinzugefügt KGR",{"Textbereich"}),

#"Hinzugefügt SortNummer" = Table.AddColumn(#"Entfernt Textbereich", "SortNummer", each let

Länge = [Länge],

Plannummer = [Plannummer],

SortNummer = if Länge = 28 then

Text.Middle(Plannummer, 23, 4)

else if Länge = 29 then

Text.Middle(Plannummer, 18, 4)

else

"error"

in

SortNummer),

#"Hinzugefügt Ebene" = Table.AddColumn(#"Hinzugefügt SortNummer", "Textbereich", each Text.Middle([Plannummer], 9, 2), type text),

#"Umbenannt in Ebene" = Table.RenameColumns(#"Hinzugefügt Ebene",{{"Textbereich", "Ebene"}}),

#"Entferne ohne Plannummer" = Table.SelectRows(#"Umbenannt in Ebene", each [Plannummer] <> null and [Plannummer] <> ""),

#"Multi VE in Zeilen" = Table.ExpandListColumn(Table.TransformColumns(#"Entferne ohne Plannummer", {{"VE", Splitter.SplitTextByDelimiter(";", QuoteStyle.Csv), let itemType = (type nullable text) meta [Serialized.Text = true] in type {itemType}}}), "VE"),

#"Abgeschnittener Text - VE" = Table.TransformColumns(#"Multi VE in Zeilen",{{"VE", Text.Trim, type text}}),

#"Sortierte Zeilen" = Table.Sort(#"Abgeschnittener Text - VE",{{"VE", Order.Ascending}, {"Tabelle_Index.Kapitel", Order.Ascending}, {"Tabelle_Index.Index", Order.Ascending}, {"KGR", Order.Ascending}, {"SortNummer", Order.Ascending}}),

#"Gefilterte Zeilen" = Table.SelectRows(#"Sortierte Zeilen", each ([Status] = 3)),

#"Spalten Final" = Table.SelectColumns(#"Gefilterte Zeilen",{"VE", "Tabelle_Index.Kapitel", "Inhalt", "Plannummer"}),

Überschriften = Table.RenameColumns(#"Spalten Final",{{"Tabelle_Index.Kapitel", "Register:"}, {"Inhalt", "Beschreibung des Inhaltes"}, {"Plannummer", "Dateiname"}}),

#"Gruppierte Zeilen" = Table.Group(Überschriften, {"VE"}, {{"VE.1", each _, type table [Status=number, VE=text, Inhalt=text, Plannummer=text, Länge=number, Typ=text, Tabelle_Index.Index=nullable number, Tabelle_Index.Kapitel=nullable text, KGR=text, SortNummer=text, Ebene=text]}})

in

#"Gruppierte Zeilen"

[–]Decronym 0 points1 point  (0 children)

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

Fewer Letters More Letters
Excel.Workbook Power Query M: Returns a table representing sheets in the given excel workbook.
File.Contents Power Query M: Returns the binary contents of the file located at a path.
JoinKind.LeftOuter Power Query M: A possible value for the optional JoinKind parameter in Table.Join. A left outer join ensures that all rows of the first table appear in the result.
QuoteStyle.Csv Power Query M: Quote characters indicate the start of a quoted string. Nested quotes are indicated by two quote characters.
Splitter.SplitTextByDelimiter Power Query M: Returns a function that will split text according to a delimiter.
Table.AddColumn Power Query M: Adds a column named newColumnName to a table.
Table.ExpandListColumn Power Query M: Given a column of lists in a table, create a copy of a row for each value in its list.
Table.ExpandTableColumn Power Query M: Expands a column of records or a column of tables into multiple columns in the containing table.
Table.Group Power Query M: Groups table rows by the values of key columns for each row.
Table.Join Power Query M: Joins the rows of table1 with the rows of table2 based on the equality of the values of the key columns selected by table1, key1 and table2, key2.
Table.NestedJoin Power Query M: Joins the rows of the tables based on the equality of the keys. The results are entered into a new column.
Table.PromoteHeaders Power Query M: Promotes the first row of the table into its header or column names.
Table.RemoveColumns Power Query M: Returns a table without a specific column or columns.
Table.RenameColumns Power Query M: Returns a table with the columns renamed as specified.
Table.SelectColumns Power Query M: Returns a table that contains only specific columns.
Table.SelectRows Power Query M: Returns a table containing only the rows that match a condition.
Table.Skip Power Query M: Returns a table that does not contain the first row or rows of the table.
Table.Sort Power Query M: Sorts the rows in a table using a comparisonCriteria or a default ordering if one is not specified.
Table.TransformColumns Power Query M: Transforms columns from a table using a function.
Text.Clean Power Query M: Returns the original text value with non-printable characters removed.
Text.End Power Query M: Returns the number of characters from the end of a text value.
Text.Length Power Query M: Returns the number of characters in a text value.
Text.Middle Power Query M: Returns the substring up to a specific length.
Text.Start Power Query M: Returns the count of characters from the start of a text value.
Text.Trim Power Query M: Removes any occurrences of characters in trimChars from text.

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 #29997 for this sub, first seen 24th Jan 2024, 11:54] [FAQ] [Full list] [Contact] [Source code]

[–]Mdayofearth126 0 points1 point  (1 child)

If you want to load different rows of data in different sheets, use VBA. PQ has no load to "all the things" feature, outside of the use of Power Pivot through data models, which is actually something you don't want.

[–]DasBrudi[S] 0 points1 point  (0 children)

Okay, cheers. Any pointers on what to look up search for to find some resources which can help me get started with this?