Forum Discussion
Anonymous
6 years agoNot applicable
Dax for Current Month & Previous Month
Hi, I'm trying to create a calculated colunm that groups dates into one of three values. Current Month - all dates that are in this month Previous Month - all dates in previous month Histor...
- 6 years ago
Hi Anonymous
try column
= IF( AND(MONTH('Table'[DateColumn])=MONTH(today());YEAR('Table'[DateColumn])=YEAR(today())); "Current Month"; IF( AND(MONTH('Table'[DateColumn])=MONTH(EOMONTH(today();-1));YEAR('Table'[DateColumn])=YEAR(EOMONTH(today();-1))); "Previous Month"; "Historic" )its possible also to add check if "future period"
do not hesitate to give a kudo to useful posts and mark solutions as solution
az38
Community Champion
6 years agoHi Anonymous
try column
=
IF(
AND(MONTH('Table'[DateColumn])=MONTH(today());YEAR('Table'[DateColumn])=YEAR(today()));
"Current Month";
IF(
AND(MONTH('Table'[DateColumn])=MONTH(EOMONTH(today();-1));YEAR('Table'[DateColumn])=YEAR(EOMONTH(today();-1)));
"Previous Month";
"Historic"
)its possible also to add check if "future period"
do not hesitate to give a kudo to useful posts and mark solutions as solution
- Anonymous6 years agoNot applicable
Hi az38,
Thanks for this, i've added in the table and colunm names and i keep on getting error messages. Would i need to have a date table?
Please see my Dax below.
Current Month =IF(AND(MONTH('Target data'[date_logged])=MONTH(today());YEAR('Target data'[date_logged])=YEAR(today()));"Current Month";IF(AND(MONTH('Target data'[date_logged])=MONTH(EOMONTH(today();-1));YEAR('Target data'[date_logged])=YEAR(EOMONTH(today();-1)));"Previous Month";"Historic")- az386 years ago
Community Champion
Hi Anonymous
what kind of error?
it works good in my demo-project.
do not hesitate to give a kudo to useful posts and mark solutions as solution