Forum Discussion
SvenJ
4 years agoHelper III
Search for a value in another table
I have a table which has a column called "Konto" and a cell with the value of 8421 in this table. Now i want to search in another table between two columns (Konto von - Konto bis) and give back t...
- 4 years ago
Hier:
each Table.SelectRows(BWAgreift er auf die existierende BWA Tabelle zu. Anbei ein sample PBIX.
SvenJ
4 years agoHelper III
Eher so?
| Konto | Belegdatum | BU-Schlüssel |
| 8735 | 01.02.2021 | |
| 8736 | 12.07.2021 | 3 |
| 8736 | 12.07.2021 | 3 |
| 8736 | 12.07.2021 | 3 |
| 8736 | 21.10.2021 | 3 |
Die zu durchsuchende Tabelle sieht wie folgt aus
| #BWA-Zeile | Bezeichnung | Konto von | Konto bis | S/H |
| 1010 | ||||
| 1020 | Umsatzerlöse | 8000 | 8195 | H |
| 1020 | Umsatzerlöse | 8200 | 8519 | H |
| 1020 | Umsatzerlöse | 8700 | 8799 | H |
| 1020 | Umsatzerlöse | 8950 | 8959 | H |
| 1040 | Best.Verdg. FE/UE | 8960 | 8989 | H |
| 1045 | Akt.Eigenleistungen | 8990 | 8999 | H |
lbendlin
4 years agoSuper User
Use your existing BWA table and then add this one:
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("dcmxCcAwDATAVYJqI15vFEWzGO+/RkSMIY3L48aQJ7pLE5iCStAKl8z2zV0wKmJPX5OOw3geJjKzQFPDb+YL", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Konto = _t, Belegdatum = _t, #"BU-Schlüssel" = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Konto", Int64.Type}}),
#"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each Table.SelectRows(BWA,(k)=>k[Konto von]<=[Konto] and [Konto]<=k[Konto bis])),
#"Expanded Custom" = Table.ExpandTableColumn(#"Added Custom", "Custom", {"#BWA-Zeile"}, {"#BWA-Zeile"})
in
#"Expanded Custom"
How to use this code: Create a new Blank Query. Click on "Advanced Editor". Replace the code in the window with the code provided here. Click "Done".
- SvenJ4 years agoHelper III
Sorry, ich kann dir nicht folgen - was hat die Json damit zu tun. Ich habe eine Tabelle, in der die ganzen Daten gespeichert sind und nicht nur die 4 Zeilen - das war nur ein Ausschnitt. Kannst du mir da helfen?
- lbendlin4 years agoSuper User
Das ist kein JSON, das ist Power Query M code.
How to use this code: Create a new Blank Query. Click on "Advanced Editor". Replace the code in the window with the code provided here. Click "Done".