Forum Discussion
Formatting Date
- 3 years ago
Hey,
You can perform this task by creating a new column and by after that using DAX formula
PeriodCode =
VAR CurrentDate = YourTableName[DateColumn]
VAR StartDate = DATE(2023, 5, 21) // Update with your desired start date
VAR DaysDiff = DATEDIFF(StartDate, CurrentDate, DAY)
VAR PeriodNumber = CEILING(DaysDiff / 28, 1)
RETURN
SWITCH(
TRUE(),
AND(DaysDiff >= 0, DaysDiff < 28), "P" & PeriodNumber,
AND(DaysDiff >= 28, DaysDiff < 56), "P" & (PeriodNumber + 1),
AND(DaysDiff >= 56, DaysDiff < 84), "P" & (PeriodNumber + 2),
// Add more cases for other periods as needed
"Unknown"
)
After that in modeling tab change the format into text and after using the new calculated column you can achieve your desired output.
Thank you. Hope this will help.
Hey,
You can perform this task by creating a new column and by after that using DAX formula
PeriodCode =
VAR CurrentDate = YourTableName[DateColumn]
VAR StartDate = DATE(2023, 5, 21) // Update with your desired start date
VAR DaysDiff = DATEDIFF(StartDate, CurrentDate, DAY)
VAR PeriodNumber = CEILING(DaysDiff / 28, 1)
RETURN
SWITCH(
TRUE(),
AND(DaysDiff >= 0, DaysDiff < 28), "P" & PeriodNumber,
AND(DaysDiff >= 28, DaysDiff < 56), "P" & (PeriodNumber + 1),
AND(DaysDiff >= 56, DaysDiff < 84), "P" & (PeriodNumber + 2),
// Add more cases for other periods as needed
"Unknown"
)
After that in modeling tab change the format into text and after using the new calculated column you can achieve your desired output.
Thank you. Hope this will help.