Forum Discussion
Change Date format to YYYYMM
- 7 years ago
Hi,
In the Date Table, write this calculated column formula
=FORMAT('Date'[Date],"YYYYMM")
In the slier, drag this column.
Hope this helps.
Hi,
My formula is a calculated column formula (DAX not M). It looks like you are trying to write my formula in the Query Editor. I can offer further help if you share the PBI file.
Also, for creating the Calendar Table, go to Modelling > New Table and write this formula there
=CALENDAR(MIN(Data[Date]),MAX(Data[Date]))
Now create a relationship from the Date column of your Data Table to the Date column of the Calendar Table.
Hi Ashish,
Please find the sample PBI file in the link below -
https://drive.google.com/file/d/1Vfo0iq57F2FJxnMQxH6QYYrBWl1XWVC9/view?usp=sharing
File Name: Difference Report - Sample Data Method 1
In this, the Year Month in the dropdown selections should be of format "YYYYMM".
This report is needed for a specific requirement.
Let me know if you need anything else.
Thanks,
Vishy
- Ashish_Mathur7 years ago
Super User
Hi,
In the Date Table, write this calculated column formula
=FORMAT('Date'[Date],"YYYYMM")
In the slier, drag this column.
Hope this helps.
- Anonymous7 years agoNot applicable
Hi Ashish,
Thanks, that worked.
But I had a question since we are formatting the date as a Text now using the FORMAT function, will it impact the relationship or calculations.
Eg: User selects 201902 i.e. Feb 2019 in the dropdown, will the measures and calculated columns work as usual? I'm clarifying because 201902 is of Text format whereas the calculations are based on date selected by end user.
Please correct me if I am understanding incorrectly.
Thanks,
Vishy
- Ashish_Mathur7 years ago
Super User
Hi,
This is another column you have created in the Calendar Table. Since the Date column stays intact and that is the column you hae built the relationship to, all measures and columns will work as expected.
- Anonymous3 years agoNot applicable
Hello Ashish,
I have similar kind of problem.
When I use above solution, then I am not able to convert "YYYYMM" format to Date. It shows as text. I want this format to be converted to date as I am performing time intelligence calculations on it.
Do you know anyother solution for it ?
Thank you for help.
- Ashish_Mathur3 years ago
Super User
Hi,
Try this calculated column formula
=date(left(Data[Date],4),right(Data[Date],2),1)