Aahi
Aahi

Reputation: 19

Tableau Convert Date to first date of the month

How can I convert any date to first of the month in tableau while retaining month as 2 digits and format as date?

I have tried

INT("01" + "-" + STR(MONTH([Date])) + "-" + STR(YEAR(Date))) which returns month as single digit
Date Converted Date
9/01/2020 1/01/2020
10/01/2020 1/01/2020
5/03/2021 1/03/2021
12/03/2021 1/03/2021

Upvotes: 0

Views: 1271

Answers (1)

Fabio Fantoni
Fabio Fantoni

Reputation: 3167

You can create a calculated field like this:

MAKEDATE(YEAR([Date]),MONTH([Date]),1)

If you're using a live connection, it all depends on the source you're connecting to.

You can also try:

date(
right('0'+str(month([Order Date])),2)
+
'01'
+
str(year([Order Date]))
)

Just remember to right-click your CF --> Default Properties --> Date Format

You should get something like this: enter image description here

Upvotes: 1

Related Questions