Forum Discussion
If/Else For 2 Tables
First, I have to say, this user community is AWESOME! Everyone is so professional in the way they handle questions and responses that I do not see in other user groups.
Now, I have a report I am building that has a query pulling information from our IBM DB2 system and a table that I created. Each of these have a PALLET_LOC field. I have a relationship between these based on the PALLET_LOC field and the table has a LocationTag field (value: Exclude) that gets returned to my report. My issue is that if the PALLET_LOC is in the exclude table, then is putting Exclude out in the report, but I need to have it output Include if the PALLET_LOC is not in the table. I am used to other languages if/else statements to do this, but PB is causing me issues. I know I could do a Conditional Column and have each location in the if/else statement, but it would be easier to maintain if I had only had to add a value to the table to update the report.
if the relationship between warehouse table and location table is many to one
you can try this
Column = if( RELATED(PalletLocation[LOC_TAG])="","Include",RELATED(PalletLocation[PALLET_LOC]))pls see the attachment below
7 Replies
- StachuCommunity Champion
Can you add sample tables (in format that can be copied to PowerBI) from your model with anonymised data? Like this (just copy and paste into the post window).
Column1 Column2 A 1 B 2.5 - leebaldwinHelper I
Stachu Thank you. I wasn't sure what information you might need. Here are the 2 tables in question. I am doing a one-to-many relationship on these.
qryWarehousePallet
ORD_NUM SKU PALLET_LOC LOC_TAG 246 ABC9 Q6PLT EXCLUDE 998 EED H107A INCLUDE tblPalletLocation
PALLET_LOC LOC_TAG Q6PLT Exclude LOCQ6 Exclude Q601A Exclude FLOOR Exclude MIA01 Exclude - ryan_mayuSuper User
what's the expected output based on your sample data?
- leebaldwinHelper I
Based on the sample data, if qryWarehousePallet.PALLET_LOC is in tblPalletLocation.PALLET_LOC, then it returns tblPalletLocation.LOC_TAG, which would be Exclude, else it returns the word Include.