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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

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
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 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.