Forum Discussion
_Kelz0484
1 year agoFrequent Visitor
DAX for finding matches in multiple columns
Hi, Hope I'm posting this in the right place. I'm trying to write a DAX command to find if a column that contains a certificate number matches two other columns within the same table. Column 1 Cer...
- 1 year ago
You could create a calculated column like
Match = VAR DateToCheck = RIGHT ( 'Table'[Column1], 10 ) VAR NumberToCheck = LEFT ( 'Table'[Column1], 20 ) -- Replace the logic here as needed VAR AllSerialNos = CALCULATETABLE ( ALL ( 'Table'[Column2] ), 'Table'[Column4] = DateToCheck ) VAR AllBatchNos = CALCULATETABLE ( ALL ( 'Table'[Column3] ), 'Table'[Column4] = DateToCheck ) VAR Result = IF ( NumberToCheck IN AllSerialNos || NumberToCheck IN AllBatchNos, "Match", "Discrepancy" ) RETURN ResultYou'll need to change the logic splitting out the number from the date appropriately, and you may need to manipulate the date data to get it in date format to match Column4
johnt75
Super User
1 year agoYou could create a calculated column like
Match =
VAR DateToCheck =
RIGHT ( 'Table'[Column1], 10 )
VAR NumberToCheck =
LEFT ( 'Table'[Column1], 20 ) -- Replace the logic here as needed
VAR AllSerialNos =
CALCULATETABLE ( ALL ( 'Table'[Column2] ), 'Table'[Column4] = DateToCheck )
VAR AllBatchNos =
CALCULATETABLE ( ALL ( 'Table'[Column3] ), 'Table'[Column4] = DateToCheck )
VAR Result =
IF (
NumberToCheck
IN AllSerialNos
|| NumberToCheck IN AllBatchNos,
"Match",
"Discrepancy"
)
RETURN
Result
You'll need to change the logic splitting out the number from the date appropriately, and you may need to manipulate the date data to get it in date format to match Column4
- _Kelz04841 year agoFrequent Visitor
Thank you. This worked perfect!