Forum Discussion
DAX next month
Hi,
I am trying to create a column in my Date table that indicates the next month of the current date. My column reads:
IsNextMonth2 =
Month(Dates[Date]) = MONTH(NOW() + 1)
It is reading True for December 2022 and False for all other months. But I want it to read True for January 2023 and False for all over months. Any suggestions? Thank you!
- Anonymous3 years ago
Hi Benedict21
Try the code:
Is Next_month = var to_date = EOMONTH(TODAY(),1)return YEAR('Month'[Date])=YEAR(to_date)&&MONTH('Month'[Date])=MONTH(to_date)Best Regards!
Yolo Zhu
7 Replies
- amitchandak
Super User
Benedict21 , Try like
eomonth(Date[Date],0) = eomonth(Today(),1)
Month Type = Switch( True(),
eomonth(Date[Date],0) = eomonth(Today(),0) ,"Current Month" , //This Month
eomonth(Date[Date],0) = eomonth(Today(),-1) && ,"Previous Month" , //last Month
eomonth(Date[Date],0) = eomonth(Today(),1) && ,"Next Month" , //last Month
[Month Year]
)- Benedict21Frequent Visitor
Hi! Thank you but I am getting a lot of incorrect syntax: Cannot find name 'Date'.
- AnonymousNot applicable
Hi Benedict21 ,
You can try the following code I modified:
IsNextMonth2 =
Month(Dates[Date]) = MONTH(MONTH(NOW())+1)
Best Regards,
Yolo Zhu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
- Benedict21Frequent Visitor
Hi!
Thank you but this is only capturing the next month value, not the month and year value.
- AnonymousNot applicable
Hi Benedict21
You can try the following code:
var to_date=EOMONTH(TODAY()),1)
return MONTH('Month'[Date])=MONTH(to_date)Best Regards,
Yolo Zhu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.