Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
I have a column in Calender table to identify last six months and the formula is-
Solved! Go to Solution.
@learner03 maybe I'm not fully understanding what you're trying to do, but it seems to me that your formula could be simplified significantly to something like :
Last 6 Months =
VAR _CurrentDate = MAX('Calendar'[Date])
VAR _Result =
IF(
DATEDIFF('Calendar'[Date],_CurrentDate,MONTH) < 6,
'Calendar'[MonthYear],
"Neither"
)
Return
_Result
Hi @learner03
Try this:
6 months =
VAR _A =
MAX ( 'Calendar'[Date] )
VAR _AM =
MONTH ( _A )
VAR _6M =
IF (
_AM >= 6,
DATE ( YEAR ( _A ), _AM - 5, 01 ),
DATE ( YEAR ( _A ) - 1, 12 - ( 5 - _AM ), 01 )
)
RETURN
IF (
'Calendar'[Date] >= _6M
&& 'Calendar'[Date] <= _A,
'Calendar'[MonthYear],
"Neither"
)
If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
LinkedIn: www.linkedin.com/in/vahid-dm/
Hi @learner03
Try this:
6 months =
VAR _A =
MAX ( 'Calendar'[Date] )
VAR _AM =
MONTH ( _A )
VAR _6M =
IF (
_AM >= 6,
DATE ( YEAR ( _A ), _AM - 5, 01 ),
DATE ( YEAR ( _A ) - 1, 12 - ( 5 - _AM ), 01 )
)
RETURN
IF (
'Calendar'[Date] >= _6M
&& 'Calendar'[Date] <= _A,
'Calendar'[MonthYear],
"Neither"
)
If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
LinkedIn: www.linkedin.com/in/vahid-dm/
@learner03 maybe I'm not fully understanding what you're trying to do, but it seems to me that your formula could be simplified significantly to something like :
Last 6 Months =
VAR _CurrentDate = MAX('Calendar'[Date])
VAR _Result =
IF(
DATEDIFF('Calendar'[Date],_CurrentDate,MONTH) < 6,
'Calendar'[MonthYear],
"Neither"
)
Return
_Result
The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!
Check out the November 2025 Power BI update to learn about new features.
| User | Count |
|---|---|
| 66 | |
| 48 | |
| 43 | |
| 26 | |
| 19 |
| User | Count |
|---|---|
| 198 | |
| 126 | |
| 102 | |
| 67 | |
| 50 |