Forum Discussion
IF Table Column Contains Matching Value Place Another Value in New Column
- 5 years ago
Hi,
This calculated column formula works
=if(ISBLANK(FIRSTNONBLANK(FILTER(VALUES(code_names[Unique Code]),SEARCH(code_names[Unique Code],Data[Original Title],1,0)),1)),Data[Original Title],FIRSTNONBLANK(FILTER(VALUES(code_names[Unique Code]),SEARCH(code_names[Unique Code],Data[Original Title],1,0)),1)&" ("&LOOKUPVALUE(code_names[Symbolic Name],code_names[Unique Code],FIRSTNONBLANK(FILTER(VALUES(code_names[Unique Code]),SEARCH(code_names[Unique Code],Data[Original Title],1,0)),1))&")")Hope this helps.
No relationship needs to be created. I cannot say why it is not working on your file.
So I figured out what the problem was. I created the column in the wrong table. I forget for certain DAX functions the corresponding value has to be in the same table. Now with that said I don't get any errors from the DAX but when activating the column all of the rows are
0 (Success)
I am assuming this means the function is working but can't find anything. I checked the code_names[Unique Code] tablle and the codes that are in Data[Original Title] are indeed there.
Any thoughts?
- Ashish_Mathur5 years ago
Super User
There has to be some spelling error or some extra spaces/invisible characters.
- vijenkin5 years ago
Microsoft Employee
So I believe I figured what the porblem is.
In the code_names[Unique Code] table there is a row that contains "0 (Success)" because that is the error code for success. Originally I did remove that row as the report should only have failures so success is not needed. However, afterwards the column showed "1 (another Error name)" . Therefore this makes me believe that there is something with the function that is searching through the Unique Code table which does not account for values equal to the two examples I just listed. For more context the Unique Code table looks like the below and has over 60K rows.
Unique Code Symbolic Name 0 Success 1 Security Error 2 Server Error .... ...... 000000 Client Error 000001 Network Error .... ..... 012345 Network Error 67890 Server Error 24680 Client Error I did try the query with just the examples I included in the original post and that produces the expected results, so I know the query works. However, given the code_names[Unique Code] table has more a lot more values than that is there some modification that should be made to the query?
- Ashish_Mathur5 years ago
Super User
Hi,
I have lost track of your requirement now. Share a small representative dataset(s), describe the question and show the expected result.