Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Anonymous
Not applicable

Using while-loop to increment an adder by 1 each time it sees a value

table1

yearforecasted_month
202312
20231
20232

 

I have a table that looks like this and I want to create a new column called forecasted_year where it adds 1 to year whenever forecasted_month hits 1 again.

 

My expected outcome would look like this if it works as intended

forecasted_year
2023
2024
2024

 

Is there any way to do this in DAX or Power Query? 

1 REPLY 1
lbendlin
Super User
Super User

Neither DAX nor Power Query have a concept of mutable variables. You need to bring your own index column to make this work.

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.