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
Tinus1905
Resolver I
Resolver I

Previous period

Hi,

 

In PowerBi query editor I want to have a column of the previous period. 

The year periods are: Week 1-4 is period 1, week 5-8 is period 2 etc etc. If a year has 53 weeks then week 53 belongs to periode 13. 

My table looks like this: 

 

DateWeekPeriodCurrent week
1-1-202411False
2-1-202411False
8-1-202421False
9-1-202421False
15-1-202431False
16-1-202431False
22-1-202441False
23-1-202441False
29-1-202452False
30-1-202452False
5-2-202462False
6-2-202462False
12-2-202472False
13-2-202472False
19-2-202482True
20-2-202482True

 

This is what I want:

 

DateWeekPeriodCurrent weekPrevious period
1-1-202411FalseTrue
2-1-202411FalseTrue
8-1-202421FalseTrue
9-1-202421FalseTrue
15-1-202431FalseTrue
16-1-202431FalseTrue
22-1-202441FalseTrue
23-1-202441FalseTrue
29-1-202452FalseFalse
30-1-202452FalseFalse
5-2-202462FalseFalse
6-2-202462FalseFalse
12-2-202472FalseFalse
13-2-202472FalseFalse
19-2-202482TrueFalse
20-2-202482TrueFalse

 

Can anyone help me with this?

1 ACCEPTED SOLUTION

In your Advanced Editor, Delete all other existing lines aftrer #"Added Custom3". Use these 3 lines after #"Added Custom3" step. 

 

    CurrentWeek = #"Added Custom3"[Period]{List.PositionOf(#"Added Custom3"[Current week], true)} - 1,
    #"Added Custom" = Table.AddColumn(#"Added Custom3", "Previous period", each [Period] = CurrentWeek)
in
    #"Added Custom"

 

 

View solution in original post

8 REPLIES 8
Vijay_A_Verma
Super User
Super User

Use this formula in a custom column where #"Changed Type" is your previous step

[Period] = #"Changed Type"[Period]{List.PositionOf(#"Changed Type"[Current week], true)} - 1

 

@Vijay_A_Verma 

You mean putting it in the advanced editor or open custom column and then the code is: 

= #"Changed Type"[Period]{List.PositionOf(#"Changed Type"[Current week], true)} - 1

I don't understand it completely. 

This is the end of my advanced editor: 

 

#"Added Custom3" = Table.AddColumn(#"Added Custom2", "Current week", each Date.IsInCurrentWeek([Date]))
in
#"Added Custom3"

Click on Custom Column in Add Column menu and paste the formula which I have given. Replace #"Changed Type" with #"Added Custom3". This will become

#"Added Custom3"[Period]{List.PositionOf(#"Added Custom3"[Current week], true)} - 1

@Vijay_A_Verma ok, this what I get:

 

Tinus1905_0-1708439944602.png

 

But this is what I want, so I can use a filter on true or false in the previous period column. 

 

Tinus1905_1-1708440004011.png

 

Have you paste the query properly which I had given? See below, you will exactly get the same output which you are asking. 

1.png

@Vijay_A_Verma ah I forgot the first "period". But I have a little problem with my dataset. 

I have a table with +- 80.000 rows and with this formula it is loading and loading and loading for hours. 

Is there an other formula for this. I dont mind if its a column with true, false, 1 ,2 etc. I only want to filter so that the period is the previous period. 

In your Advanced Editor, Delete all other existing lines aftrer #"Added Custom3". Use these 3 lines after #"Added Custom3" step. 

 

    CurrentWeek = #"Added Custom3"[Period]{List.PositionOf(#"Added Custom3"[Current week], true)} - 1,
    #"Added Custom" = Table.AddColumn(#"Added Custom3", "Previous period", each [Period] = CurrentWeek)
in
    #"Added Custom"

 

 

@Vijay_A_Verma it works!!! Thanks for your help. 

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

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!

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.