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

FIlter Current week

Hi I have a table that I want filter away before loading in power bi, I have several week of data and just want to have current week.

I have only yearweek in my fact table, im using same table to several reports.
Thanks

1 ACCEPTED SOLUTION

 

You need to add a step name if you're putting it straight into Advanced Editor.

It would look something like this:

// This:

let
    Source = YourSource,
    SomeChanges = Function(Source, each DoStuff)
in
    SomeChanges

// ...would go to this:

let
    Source = YourSource,
    FilterRows = 
        Table.SelectRows(
            Source,
            each [YearWeek] = List.Max(Source[YearWeek])
        )
    SomeChanges = Function(FilterRows, each DoStuff)
in
    SomeChanges

 

Pete

 



Now accepting Kudos! If my post helped you, why not give it a thumbs-up?

Proud to be a Datanaut!




View solution in original post

6 REPLIES 6
Vijay_A_Verma
Most Valuable Professional
Most Valuable Professional

You can choose Transform data while pulling in the data into Power BI and in Transform Data (i..e. Power Query), you can reduce the amount of data before lading into Power BI. 

Ideally the best way is to way put a SQL query into your Power BI import so that data pulled from database is also lesser.

In first approach, full data will be imported but Power BI will be loaded with only required rows after you transform data.

If you use SQL Query to pull in only required rows, then operation will be faster as only required rows are imported.

BA_Pete
Super User
Super User

Hi @Anonymous ,

 

If your YearWeek column is an integer e.g. 202301, 202341 etc. then the following filter should work:

Table.SelectRows(
    previousStepName,
    each [YearWeek] = List.Max(previousStepName[YearWeek])
)

 

Pete



Now accepting Kudos! If my post helped you, why not give it a thumbs-up?

Proud to be a Datanaut!




Anonymous
Not applicable

Hi got this when try to add it in Advanced editor
Table.SelectRows( (Token '=' expected.)
previousStepName,
each [YearWeek] = List.Max(previousStepName[YearWeek])
Regard

 

You need to add a step name if you're putting it straight into Advanced Editor.

It would look something like this:

// This:

let
    Source = YourSource,
    SomeChanges = Function(Source, each DoStuff)
in
    SomeChanges

// ...would go to this:

let
    Source = YourSource,
    FilterRows = 
        Table.SelectRows(
            Source,
            each [YearWeek] = List.Max(Source[YearWeek])
        )
    SomeChanges = Function(FilterRows, each DoStuff)
in
    SomeChanges

 

Pete

 



Now accepting Kudos! If my post helped you, why not give it a thumbs-up?

Proud to be a Datanaut!




Anonymous
Not applicable

Hi the code doesnt work

 

What doesn't work? Do you get an error? Do you not get the result you're expecting? What?

 

Pete



Now accepting Kudos! If my post helped you, why not give it a thumbs-up?

Proud to be a Datanaut!




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!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.

Top Solution Authors