Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
SvenJ
Helper III
Helper 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 the value #BWA-Zeile.SvenJ_1-1642964232887.png

How can i do that in Power Query? I know how to do it as a calculated column, but this value is not in Power Query. Can someone help me?

1 ACCEPTED SOLUTION

Hier:

each Table.SelectRows(BWA

greift er auf die existierende BWA Tabelle zu.  Anbei ein sample PBIX.

 

View solution in original post

14 REPLIES 14
SvenJ
Helper III
Helper III

Und an welcher Stelle greift er auf welche Tabelle zu?

Hier:

each Table.SelectRows(BWA

greift er auf die existierende BWA Tabelle zu.  Anbei ein sample PBIX.

 

Many thanks for your help! Vielen lieben Dank!

SvenJ
Helper III
Helper III

@lbendlin This is not a problem - i can fix it to 8599 and start the other line with 8600

That would be better. Please provide sanitized sample data that fully covers your issue. Paste the data into a table in your post or use one of the file services. 

This is the table, where i have the values, which i need called "BWA" - i need the value BWA_Zeile, if the value is between "Konto von" and "Konto bis" 

 

SvenJ_0-1643121902016.png

And i need the value in this table called "Import"

 

SvenJ_1-1643122017049.png

 

Kannst Du das bitte in benutzbarem (kopierbarem) Format posten?  Bilder sind nicht sehr hilfreich.

Eher so?

KontoBelegdatumBU-Schlüssel
873501.02.2021 
873612.07.20213
873612.07.20213
873612.07.20213
873621.10.2021

3

 

Die zu durchsuchende Tabelle sieht wie folgt aus

 

#BWA-ZeileBezeichnungKonto vonKonto bisS/H
1010    
1020 Umsatzerlöse80008195H
1020 Umsatzerlöse82008519H
1020 Umsatzerlöse87008799H
1020 Umsatzerlöse89508959H
1040 Best.Verdg. FE/UE89608989H
1045 Akt.Eigenleistungen89908999H

 

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".

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?

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".
lbendlin
Super User
Super User

Please provide sanitized sample data that fully covers your issue. Paste the data into a table in your post or use one of the file services. 

Your "Konto von" and "Konto bis" value ranges seem to be overlapping? What would be the expected outcome for Kontonummer 8600 ?

I would fill down the column "'#BWA_Zeile", means the result should always the column "BWA_Zeile" - in this case "1017"

My point is that 8600 should not be present in both ranges.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors
Top Kudoed Authors