Forum Discussion
Add a period type column
- Anonymous5 years ago
Why are you using an incorrect tool for the job at hand? Would it not be 10000000000 times easier to do all of this in Power Query? Most of this is just a mouse click away... What's more, you'll find read-made M code on the net that builds all of this and even more for you. Please do use the right tool for the job.
On top of that, a proper date table contains all years with all their days, without any gaps and miscontinuations. It seems you're not following this Best Practice.
- Anonymous5 years ago
Hi Anonymous ,
You can update the formula of your calculated table as below:
Date =
VAR _cal =
CALENDAR (
MIN ( 'FactAssignmentByDay'[TIMEBYDAY_DT] ),
MAX ( 'FactAssignmentByDay'[TIMEBYDAY_DT] )
)
VAR _temptab =
ADDCOLUMNS (
_cal,
"Year", YEAR ( [Date] ),
"Month num", MONTH ( [Date] ),
"Month", FORMAT ( [Date], "MMM" ),
"Month LB", CONCATENATE ( FORMAT ( [Date], "YYYY" ), CONCATENATE ( "M", MONTH ( [Date] ) ) ),
"Quarter", CONCATENATE ( "Q", QUARTER ( [Date] ) ),
"Quarter LB",
CONCATENATE (
FORMAT ( [Date], "YYYY" ),
CONCATENATE ( "Q", QUARTER ( [Date] ) )
),
"Semester", IF ( MONTH ( [Date] ) <= 6, "S1", "S2" ),
"Semester LB",
IF (
MONTH ( [Date] ) <= 6,
CONCATENATE ( FORMAT ( [Date], "YYYY" ), " S1" ),
CONCATENATE ( FORMAT ( [Date], "YYYY" ), " S2" )
)
)
RETURN
UNION (
SELECTCOLUMNS (
_temptab,
"Year", [Year],
"Month num", [Month num],
"Month", [Month],
"Quarter", [Quarter],
"Semester", [Semester],
"Label", [Quarter LB],
"TimePeriod", "Quarter"
),
SELECTCOLUMNS (
_temptab,
"Year", [Year],
"Month num", [Month num],
"Month", [Month],
"Quarter", [Quarter],
"Semester", [Semester],
"Label", [Month LB],
"TimePeriod", "Month"
),
SELECTCOLUMNS (
_temptab,
"Year", [Year],
"Month num", [Month num],
"Month", [Month],
"Quarter", [Quarter],
"Semester", [Semester],
"Label", [Semester LB],
"TimePeriod", "Semester"
)
)Best Regards
Why are you using an incorrect tool for the job at hand? Would it not be 10000000000 times easier to do all of this in Power Query? Most of this is just a mouse click away... What's more, you'll find read-made M code on the net that builds all of this and even more for you. Please do use the right tool for the job.
On top of that, a proper date table contains all years with all their days, without any gaps and miscontinuations. It seems you're not following this Best Practice.