Forum Discussion
Using values from two tables to create a calculated DAX column with Switch()/IN() statement
Hi Semipro211
Please see the attached file with a solution in Power Query
Mariusz
If this post helps, then please consider Accepting it as the solution.
Please feel free to connect with me.
- Semipro2116 years agoRegular Visitor
Hi Mariusz
Thank you for taking the time to respond. I am surprised how simple the M code is to do this! I did run into one issue though. When I attempt to duplicate this code in my own pbix project, my expanded custom column gives me null values. Due to the sensitive nature of the actual information I am working with, I cannot post my pbix file, but I can at least give the structure of the two real tables with their actual column names and some dummy data. All columns are text columns.
AD Complete
CN TWWSOV00985231N LWYKTC21443004L EXANNZ20187333M NCOM20071133W CLC_CSI
CLC CSI 985 WSOV 21443 YKTC 20187 ANNZ 20071 ANNZ let (ommitted for brevity) #"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each Table.SelectRows( CLC_CSI, (b) => Text.Contains( [CN], b[CLC] ) ) ), #"Expanded Custom" = Table.ExpandTableColumn(#"Added Custom", "Custom", {"CSI"}, {"CSI"}) in #"Expanded Custom"I don't get any errors, but every value is null.
- Semipro2116 years agoRegular Visitor
Mariusz Allow me to correct myself, I must have misinterpretted part of the M code in your solution, when I changed b[CLC] to b[CSI], the column now works as expected/hoped.
THANK YOU!