The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
Hi All,
I have a simple requirement to create a new column ( dynemically changes every year) to one of the existing table.
example: I have two one column in table called Year_id and I want to add new column ( e.g. called new_column) where it shows 1 where year_id is current year and current year+1. so for current year 2022, new column shows 1 for 2022 and 2023, but Next Year ( in 2023) the new column shows 1 for 2023 and 2024, and so on.. hence I don't have to change the flag every year....
I assume it's simple in to write DAX but I am having hardtime so need help here. Thank you in advance!
Solved! Go to Solution.
Thank you AlexisOlson. That is what I was looking for. I did not know the DAX formula. It worked.
my formula is like below now and it worked. Thank you again!
You can use TODAY to get the current date and, thus, the current year.
IF ( YEAR ( TODAY() ) IN { Table1[Year_id], Table1[Year_id] - 1 }, 1, 0 )
Edit: Sorry. ^This^ is for a calculated column in DAX, not the Power Query language M but you can write similar code there.
if List.Contains({[Year_id], [Year_id]+1}, Date.Year(DateTime.LocalNow())) then 1 else 0
Thank you AlexisOlson. That is what I was looking for. I did not know the DAX formula. It worked.
my formula is like below now and it worked. Thank you again!