The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredCompete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.
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!
User | Count |
---|---|
24 | |
10 | |
8 | |
7 | |
6 |
User | Count |
---|---|
31 | |
12 | |
10 | |
10 | |
9 |