This formula displays 0 when there is no value in the Cell

SACHIN B 0 Reputation points
2025-12-04T09:01:20.7+00:00

Hello MS,

I am using this formula

=TEXTJOIN(", ", TRUE, UNIQUE(FILTERXML("<a><b>" & SUBSTITUTE(AD3 & "," & AD2, ",", "</b><b>") & "</b></a>", "//b")))

but it gives answer 0,8 or 0,2

that means it considers 0 when there is a blank or no value.

kindly help

Regards

Microsoft 365 and Office | Excel | For education | Windows
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Tamara-Hu 9,045 Reputation points Microsoft External Staff Moderator
    2025-12-04T09:45:47.6866667+00:00

    Hello @SACHIN B,  

    Thank you for posting your valuable question on Microsoft Q&A forum.   

    Based on your formula and the issue you’re facing, here’s what I understand: 

    • You’re trying to combine values from AD2 and AD3, remove duplicates, and ignore blanks. 
    • The current formula using FILTERXML is returning unexpected results like 0,8 or 0,2 because empty <b> tags are created when a cell is blank. Excel interprets these empty nodes as 0. 

    Please let me know if I misunderstood any part of your issue or you have any additional information to share. 

    Here are a few options you may want to try:  

    Option 1: Keep XML but ignore empty tags 

    Add an XPath condition to filter out empty <b> nodes: 

    =TEXTJOIN(", ", TRUE, 
    
      UNIQUE( 
    
        FILTERXML( 
    
          "<a><b>" & SUBSTITUTE(AD2 & "," & AD3, ",", "</b><b>") & "</b></a>", 
    
          "//b[normalize-space()!='']" ))) 
    

    This ensures blanks are ignored. 

    User's image

    Option 2: Use modern Excel functions (simpler) 

    If you have Excel 365 or Excel 2021+, you can avoid XML entirely: 

    
    =TEXTJOIN(", ", TRUE, UNIQUE(FILTER(AD2:AD3, AD2:AD3 <> ""))) 
    
    
    • FILTER removes blanks. 
    • UNIQUE removes duplicates. 
    • TEXTJOIN combines values. 

    User's image

    Please let me know if this meets your expectations. Thank you for reaching out!


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment". 

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.