Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
Hi Everyone,
I'm trying to return the current year and last year in a new column. However, when I try creating a DAX formula, it keeps either giving me an error or giving me a random year:
I tried using SWITCH but that doesn't work. Any advice would be greatly appreciated.
Thanks!
Solved! Go to Solution.
Hi,
Include the bolded DAX in your FORMAT and you are good to go:
Proud to be a Super User!
For both use this kind of structure:
Proud to be a Super User!
Hi,
Include the bolded DAX in your FORMAT and you are good to go:
Proud to be a Super User!
Thank you! Can you explan what the bolded portion is doing just so I understand?
@Anonymous
So basically FORMAT recognizes your "YYYY" as date formatstring and for this to work properly you need to pass a "date" to it. Now we create a proper date in this case 1.1.2022 and take the year portion of this with FORMAT to our column.
Proud to be a Super User!
And would you know why this isn't working when I change it to switch? I'd like it to display values for This Year and Last Year
For both use this kind of structure:
Proud to be a Super User!
Thank you so much!
Check out the July 2025 Power BI update to learn about new features.
User | Count |
---|---|
24 | |
9 | |
7 | |
6 | |
6 |
User | Count |
---|---|
29 | |
11 | |
11 | |
10 | |
6 |