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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Anonymous
Not applicable

how do i create a calculated column and use a loop to add 1,2,3 to 12?

testTable

yearmthforecasted_mthforecasted_year
2023992023
20239102023
20239112023
20239122023
2023912024
2023922024
2023932024
2023942024
2023952024
2023962024
2023972024
2023982024

 

The table above is a sample of what I'm working on.

 

For context, I need a way to add 1 to forecasted_mth. If its more than 12, it would -12 from it. My real data would be much more than 12 rows, so this is just a sample.

 

I filled out forecasted_mth and forecasted_year to show what its supposed to look like.

 

I know PowerBI doesn't have loops, but is there a way to do what I want?

 

Thanks

8 REPLIES 8
ChiragGarg2512
Solution Sage
Solution Sage

ChiragGarg2512_0-1695199608126.png

Check all the options and data types.

 

Anonymous
Not applicable

you're doing +1 for frcstd_mnth. I want to do it on mnth which is all 9's. So your dax doesn't really work.

 

What i want to achieve is +1 for the first row, +2 for the second, ..., and +12 for the last row.

You can introduce an INDEX column by going to powerQuery. Go to add column-> Index column -> from 1. 

The expression then can be changed to adding index to mnth column and if that sum goes above 12, then the desired changes can be applied.

 

Anonymous
Not applicable

well, that could work here. But my actual dataset is huge so i don't think index would work

ChiragGarg2512
Solution Sage
Solution Sage

@Anonymous , try writing a dax for the column.

Like this:

Column = IF('Table (2)'[frcstd_mnth] = 12, -12, 'Table (2)'[frcstd_mnth]+1)
 
Anonymous
Not applicable

hey thanks for the reply. Right now there isn't forecasted_mth and I'm trying to find it. I put added that column in the original post to show what the outcome is supposed to look like.

Playing and changing the expression can lead to desired outcome.

Anonymous
Not applicable

[frcstd_mnth]+1 gives 10 for all rows. it doesn't increase the increment

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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

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.