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
Hi everyone.
I would like to create a Calendar table that contains all the dates of the previous 12 months + dates until today.
For example, if today is 3rd December 2021, the table would contain dates from 01/12/2020 to 03/12/2021.
Of course, if today is, for example, 05/01/2021, the table would contain dates from 01/12/2019 to 05/01/2021, so I need to turn back 2 years.
This is the formula I wrote:
Solved! Go to Solution.
Hi @mtrevisiol ,
Your question is not much clear to me but the code which you are trying needs to be written as mentioned below:
MyCalendar =
VAR decreased_month =
MONTH ( TODAY () ) - 1
VAR start_date =
IF (
decreased_month > 0,
DATE ( YEAR ( TODAY () ) - 1, decreased_month, 1 ),
DATE ( YEAR ( TODAY () ) - 2, decreased_month + 12, 1 )
)
RETURN
CALENDAR ( start_date, TODAY () )Thanks,
Samarth
Best Regards,
Samarth
If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
Connect on Linkedin
Hi @mtrevisiol ,
Your question is not much clear to me but the code which you are trying needs to be written as mentioned below:
MyCalendar =
VAR decreased_month =
MONTH ( TODAY () ) - 1
VAR start_date =
IF (
decreased_month > 0,
DATE ( YEAR ( TODAY () ) - 1, decreased_month, 1 ),
DATE ( YEAR ( TODAY () ) - 2, decreased_month + 12, 1 )
)
RETURN
CALENDAR ( start_date, TODAY () )Thanks,
Samarth
Best Regards,
Samarth
If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
Connect on Linkedin
The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!
| User | Count |
|---|---|
| 40 | |
| 35 | |
| 34 | |
| 31 | |
| 28 |
| User | Count |
|---|---|
| 136 | |
| 102 | |
| 68 | |
| 66 | |
| 58 |