Forum Discussion
ElvirBotic
Helper III
5 years agoTrying to build Calculated Column for Current Month and Current Year
Hello, looking to build a calculated column that will based on the date table add a new column to show three different statuses Current Month, Previous Month, and then Future Month. So, naturally for...
- Anonymous5 years ago
Hi ElvirBotic ,
Here are the steps you can follow:
1. Create calculated column.
Switch = var _currentyear=YEAR(TODAY()) var _currentmonth=MONTH(TODAY()) var _maxcurrentmonthday=EOMONTH(TODAY(),0) var _maxlastmonth=EOMONTH(TODAY(),-2) var _switch= SWITCH( TRUE(), YEAR('Table'[Date])=_currentyear&&MONTH('Table'[Date])=_currentmonth,"Current Month", YEAR('Table'[Date])=_currentyear&&MONTH('Table'[Date])=_currentmonth-1,"Previous Month", 'Table'[Date]<=_maxlastmonth,"Previous", 'Table'[Date]>_maxcurrentmonthday,"Future Month") return _switch2. Result:
Filter the data to extract representative dates to better view the results
Best Regards,
Liu Yang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly
Anonymous
5 years agoNot applicable
Hi ElvirBotic ,
Are you saying that you want to label blank values.
Here are the steps you can follow:
1. Create calculated column.
Column =
var _currentyear=YEAR(TODAY())
var _currentmonth=MONTH(TODAY())
var _switch=
SWITCH(
TRUE(),
MONTH('Table'[Date])=_currentmonth&&YEAR('Table'[Date])=_currentyear,"Current Month",
'Table'[Date] <DATE(YEAR(TODAY()),MONTH(TODAY()),1),"Previous Month",
MONTH('Table'[Date])>_currentmonth&&YEAR('Table'[Date])>=_currentyear,"Future Month")
return
IF('Table'[Date]=BLANK(),"blank",_switch)
2. Result:
Best Regards,
Liu Yang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly
- ElvirBotic5 years ago
Helper III
This would work for one year of data, but I have multiple years of data is there a way for fix to include 2020, 2019, etc?