Forum Discussion
Help witch fetching values from another table depending on conditions
- 3 years ago
- 3 years ago
I add an extra search value in the LOOKUPVALE() to match the first criteria. In the first line were checking the rule code and supplier, if they match with Data[Code]. We return the NewCategory. Otherwise the DefaultCategory.
Example:IF( LOOKUPVALUE(Rules[Code], Rules[SupplierIDCode], Data[SupplierIDCode], Rules[SupplierID], Data[SupplierID]) = Data[Code] , LOOKUPVALUE(Rules[NewCategory],Rules[Code],Data[Code]) & "From Rules" , LOOKUPVALUE(Suppliers[DefaultCategory],Suppliers[SupplierID],Data[SupplierID]) )
The relationship of the tables are setup on SupplierID - with one to many from the supplier table to both other tables:
If I change the code as you mention, it now returns a match even if there is none. (Added a new column for testing "Category2"). There is no rule for "Supplier 3" in the rules table.
I really do appreciate you taking your valuable time to help me!
Could you provide a sample .pbix file? Then I could test some things. Because I thought you connected Rules to Data and Suppliers to Data, but I was wrong.
- SomeDataDude3 years agoAdvocate I
I add an extra search value in the LOOKUPVALE() to match the first criteria. In the first line were checking the rule code and supplier, if they match with Data[Code]. We return the NewCategory. Otherwise the DefaultCategory.
Example:IF( LOOKUPVALUE(Rules[Code], Rules[SupplierIDCode], Data[SupplierIDCode], Rules[SupplierID], Data[SupplierID]) = Data[Code] , LOOKUPVALUE(Rules[NewCategory],Rules[Code],Data[Code]) & "From Rules" , LOOKUPVALUE(Suppliers[DefaultCategory],Suppliers[SupplierID],Data[SupplierID]) ) - Myshydde3 years agoFrequent Visitor
I'm not allowed to upload a file here so try if you get access with this link: https://www.dropbox.com/sh/3lcca8y78bjtzet/AACqz8wG0nGPXXcSrGbu-F9Ma?dl=0
I've added some code to my example, but I worry that all the LOOKUPVALUE() will be very taxing on the system once the real data with maybe 200-300 000 rows are calculated.