Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

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 
1 ACCEPTED SOLUTION

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

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

View solution in original post

5 REPLIES 5
MalS
Resolver III
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
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?

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

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.
Greg_Deckler
Super User
Super User

Like this?

Column3 = IF(LEN([Column1])=6,[Column1],[Column2])

@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...
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?  

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.