Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
9 years ago
Solved

Merging two columns by criteria

 Hi everyBI'ers

 

Q: How do I merge two columns by the criteria that the values from column1 and colum2 is evaluated by it's number of digits?

 

Example: I would like to merge the following two columns to a column3 so only values of 6-digit number from column1 and column2 goes into column3? 

Column1Column2Column3
5910841437 
5910798953 
5910841759 
5910840494 
7400840216 
7989538400 
7987998999 
841759744 
840768112 
7987181888 
7969201880 
8414985910 
8416325910 
8411887400 
  • Anonymous's avatar
    Anonymous
    9 years ago

    HI Anonymous,


    You can try to use below formula:

     

    if [Column1] >= 100000 then [Column1] else if [Column2] >= 100000  then [Column2] else null

     

    In addition, you can also use Number.From function to convert result from mals's formula.

     

    Regards,

    Xiaoxin Sheng

5 Replies

    • Anonymous's avatar
      Anonymous
      Not applicable

      Greg_Deckler Thanks for your answer. Would you do this as a new add'ed column in the query editor? I get the error that "IF"-function is not known here?  

  • MalS's avatar
    MalS
    Resolver III

    In the Query Editor you could click Add Column > Custom Column and enter this formula:

     

    if Text.Length([Column1]) = 6 then [Column1] else if Text.Length([Column2]) = 6 then [Column2] else null
    • Anonymous's avatar
      Anonymous
      Not applicable

      MalS Thanks for your answer, but then columns has to be converted to text, isn't it possible to do the same operation with number-columns?

      • Anonymous's avatar
        Anonymous
        Not applicable

        HI Anonymous,


        You can try to use below formula:

         

        if [Column1] >= 100000 then [Column1] else if [Column2] >= 100000  then [Column2] else null

         

        In addition, you can also use Number.From function to convert result from mals's formula.

         

        Regards,

        Xiaoxin Sheng