Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.
I have a dashboard that is navigable through a movable slicer set on Between that has a calendar in it. The formula I've set for it is:
Calendar = CALENDAR(DATE(2021,1,10),DATE(YEAR(TODAY()),MONTH(TODAY()),DAY(TODAY())))
Which is simple, my first data point happened in 2021/1/10, and the data source is updated daily with new info, hence why I put TODAY() functions in the end. This worked out perfectly for last year, but now that it's 2023 we changed our data source, and to avoid confusion while we still use that other dashboard as well as future-proof the new one, I wanted to base the calendar off an IF() function.
Calendar = IF(DATE(YEAR(TODAY()),MONTH(TODAY()),DAY(TODAY())) >= DATE(2022,12,31),
CALENDAR(DATE(2021,1,10),DATE(2022,12,31)),
CALENDAR(DATE(2021,1,10),DATE(YEAR(TODAY()),MONTH(TODAY()),DAY(TODAY())))
)
This, however, broke my queries and returned the error: "The expression specified in the query is not a valid table expression". How would I be going on doing this correctly?
Solved! Go to Solution.
hi @Anonymous
it seems the up limit of the calendar table shall be aligned with data record.
try like:
Calendar = CALENDAR( DATE(2022, 1, 10), MAX(RecordTable[Date]))
try like:
hi ,
I don't get why you're using DATE ( YEAR ( TODAY () ), MONTH ( TODAY () ), DAY ( TODAY () ) ) instead of simply TODAY ().
@Anonymous
Because I didn't know you could do that when I started this dashboard and left it as-is.
Hope this helps
hi @Anonymous
how about
Calendar = CALENDAR( DATE(2022, 1, 10), TODAY())
directly?
I mean, yes, I could do that. In fact it's what I'm using right now on my dashboard.
What I want to do is to make it so when 2024 arrives, I don't have to make a patch that my boss has to download so they don't get confused about why 2024 is selectable when there's no data available. Today there was a bit of confusion surrounding 2023 in the 2022 dashboard, which is why I thought of using the IF() statement. If it's not possible, it's fine, I just want to be able to avoid that future change if I can.
hi @Anonymous
it seems the up limit of the calendar table shall be aligned with data record.
try like:
Calendar = CALENDAR( DATE(2022, 1, 10), MAX(RecordTable[Date]))
try like:
Nice trick! I didn't know you could do that. Thanks for the help!
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
64 | |
60 | |
51 | |
36 | |
36 |
User | Count |
---|---|
81 | |
72 | |
58 | |
45 | |
44 |