Forum Discussion
Previous Month DAX Calculation
- 2 years ago
bmk
Add calculated column as follows:Previous Month = INT('Date Table'[Date] IN CALENDAR( EOMONTH( TODAY() , -2)+1 , EOMONTH( TODAY() , -1) ))
I suggest you modify your calender table date range as follows, not to have too many dates/rows. I entere 10 years back so you can chagne it in terms of years:
ADDCOLUMNS (
CALENDAR (
DATE ( YEAR ( today() ) - 10 ) ,1 ,1 ),
DATE ( YEAR ( today() ),12 ,31 ),
bmk
Add calculated column as follows:
Previous Month = INT('Date Table'[Date] IN CALENDAR( EOMONTH( TODAY() , -2)+1 , EOMONTH( TODAY() , -1) ))
I suggest you modify your calender table date range as follows, not to have too many dates/rows. I entere 10 years back so you can chagne it in terms of years:
ADDCOLUMNS (
CALENDAR (
DATE ( YEAR ( today() ) - 10 ) ,1 ,1 ),
DATE ( YEAR ( today() ),12 ,31 ),
Fowmy, the calculated column worked great, thank you. I did try to modify the Date DAX overall as per your suggestion, but I am getting a DAX syntax error. Can you please check what I am missing.
Date Table =
ADDCOLUMNS (
CALENDAR (
DATE ( YEAR ( today() ) - 10 ) ,1 ,1 ),
DATE ( YEAR ( today() ),12 ,31 ),
),
"DateAsInteger", FORMAT ( [Date], "YYYYMMDD" ),
"Year", YEAR ( [Date] ),
"Monthnumber", FORMAT ( [Date], "MM" ),
"YearMonthnumber", FORMAT ( [Date], "YYYY/MM" ),
"YearMonthShort", FORMAT ( [Date], "YYYY/mmm" ),
"MonthNameShort", FORMAT ( [Date], "mmm" ),
"MonthNameLong", FORMAT ( [Date], "mmmm" ),
"DayOfWeekNumber", WEEKDAY ( [Date] ),
"DayOfWeek", FORMAT ( [Date], "dddd" ),
"DayOfWeekShort", FORMAT ( [Date], "ddd" ),
"Quarter", "Q" & FORMAT ( [Date], "Q" ),
"YearQuarter", FORMAT ( [Date], "YYYY" ) & "/Q"
& FORMAT ( [Date], "Q" ),
"Start of Week",[Date] - WEEKDAY([Date],2) +1,
"Week Ending",[Date] + 7 - WEEKDAY([DATE],2),
"Week Range",[Date] - WEEKDAY([Date],2) +1&" - "&[Date] + 7 - WEEKDAY([DATE],2),
"MonthYear", FORMAT ( [Date], "mmmm" )&"/"&YEAR ( [Date] ),
"WeekNum",weeknum([Date],2)-1
)
- Fowmy2 years agoSuper User
bmk
I fixed it, please try now.Date Table = ADDCOLUMNS ( CALENDAR ( DATE ( YEAR ( today() ) - 10 ,1 ,1 ), DATE ( YEAR ( today() ), 12 ,31 ) ), "DateAsInteger", FORMAT ( [Date], "YYYYMMDD" ), "Year", YEAR ( [Date] ), "Monthnumber", FORMAT ( [Date], "MM" ), "YearMonthnumber", FORMAT ( [Date], "YYYY/MM" ), "YearMonthShort", FORMAT ( [Date], "YYYY/mmm" ), "MonthNameShort", FORMAT ( [Date], "mmm" ), "MonthNameLong", FORMAT ( [Date], "mmmm" ), "DayOfWeekNumber", WEEKDAY ( [Date] ), "DayOfWeek", FORMAT ( [Date], "dddd" ), "DayOfWeekShort", FORMAT ( [Date], "ddd" ), "Quarter", "Q" & FORMAT ( [Date], "Q" ), "YearQuarter", FORMAT ( [Date], "YYYY" ) & "/Q" & FORMAT ( [Date], "Q" ), "Start of Week",[Date] - WEEKDAY([Date],2) +1, "Week Ending",[Date] + 7 - WEEKDAY([DATE],2), "Week Range",[Date] - WEEKDAY([Date],2) +1&" - "&[Date] + 7 - WEEKDAY([DATE],2), "MonthYear", FORMAT ( [Date], "mmmm" )&"/"&YEAR ( [Date] ), "WeekNum",weeknum([Date],2)-1 )- bmk2 years agoHelper II
Thank you, Fowmy.