SOLVED

Concatenate dates

Iron Contributor

Hello everyone. 

 

When I try to concatenate 3 columns, one of them has dates, I get in the results column a number that equales a date. Very annoying.

 

My column formula

=CONCAT([@[Name]],"-",[@[Record _number]],"-",[@[Expiration_Date]])

 

Example Result:

John Smith-033111-43706

 

What I really want:

John Smith-033111-08/29/2019

 

Any help on this? Thanks in advance

9 Replies

@Ocasio27 

The best way to achieve your desired outcome is as follows

1. Click anywhere in your data and press CTRL + T. Ensure my data has headers is checked. 

2. Click OK

3. In the Data tab, click on From Table/Range

4. In the Power Query editor, select all the three columns 

5. Click on Merge Columns in the Add Column tab

Abiola1_0-1581362640453.png

6. In the Merger Column dialogue box, select Custom as Separator

7. In the box below, type in - (as your separator)

8. Click OK

In the caption below, you have the newly added column

 

Abiola1_1-1581362727488.png

9. Right-click on the first 3 columns and select Remove columns

10. Finally, select Close and Load in the Home tab to load the result back to Excel 

Abiola1_2-1581362871570.png

That is the final answer.

 

 

TEXTJOIN method

 

 
 
 

=TEXTJOIN("-",TRUE,D5,E5,TEXT(F5,"mm/dd/yyyy"))

See attached

 

textjoin.PNG

If this solve your question, kindly do accept as the Best Response.

 

 

Regards

 

 

 

@Ocasio27 

Alternatively, try this:

 

=CONCAT([@Name],"-",[@Record_number],"-",TEXT([@Expiration_Date],"dd/mm/yyyy"))

 

@Ocasio27 

 

In addition, you can use flash fill (programming by example)

1. Type in the values in each of the three columns and separate with - 

2. Click Enter

3. Execute CTRL + 3.

 

This is much faster

 

Abiola1_0-1581364876456.png

 

@Riny_van_Eekelen 

 

=CONCAT([@Name],"-",[@Record_number],"-",TEXT([@Expiration_Date],"dd/mm/yyyy"))

 

=CONCAT([@[Name]],"-",[@Record_number],"-",TEXT([@[Expiration_Date]],"dd/mm/yyyy"))

 

Made a slight modification. For some reason I MUST keep the first and last columns with [@[]] or else i get a mess, IDK why

@Ocasio27 

What's "IDK"?

I replicated your example as shown in the picture below. Don't understand why you must have the extra

"[@[]]". But if it works for you, that's okay, I guess.

Screenshot 2020-02-10 at 21.13.33.png

@Riny_van_Eekelen 

 
I mean I dont know

My formula bar will automatically add those []. Even if i try to change the whole formula by adding the table as reference it turns it back to those extra []. In the end, it works anyway so OK

@Ocasio27 

That's how structured references work, you may check more here Using structured references with Excel tables 

@Ocasio27 

I am now trying to do this in a Power Pivot table, it does not accept more than 2 arguments. How can I do this in power pivot.

best response confirmed by Ocasio27 (Iron Contributor)
Solution

@Ocasio27 

In DAX

image.png

you may use

=CONCATENATE(Table1[Name],CONCATENATE("-",CONCATENATE(Table1[Record Number],CONCATENATE("-",Table1[Expiration Date]))))

but much better is

=Table1[Name] & "-" & Table1[Record Number] & "-" & Table1[Expiration Date]

image.png

1 best response

Accepted Solutions
best response confirmed by Ocasio27 (Iron Contributor)
Solution

@Ocasio27 

In DAX

image.png

you may use

=CONCATENATE(Table1[Name],CONCATENATE("-",CONCATENATE(Table1[Record Number],CONCATENATE("-",Table1[Expiration Date]))))

but much better is

=Table1[Name] & "-" & Table1[Record Number] & "-" & Table1[Expiration Date]

image.png

View solution in original post