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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register 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
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.