cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Helper I
Helper I

CreateTable in Power Query

Hello,

 

In PowerQuery, How can we use Create Table from an existing table by filtering rows? 

 

Thanks

 

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Helper I
Helper I

Re: CreateTable in Power Query

Hi

I referenced DataSet &

Tried Following

 

let
Source = Data1,
#"Added Custom" = Table.AddColumn(Source, "Index", each if [Location] = "US" then "" else 0/1),
#"Changed Type" = Table.TransformColumnTypes(#"Added Custom",{{"Index", type binary}}),
#"Removed Errors" = Table.RemoveRowsWithErrors(#"Changed Type", {"Index"}),
#"Removed Columns" = Table.RemoveColumns(#"Removed Errors",{"Index"})
in
#"Removed Columns"

 

Its Working for me. 

View solution in original post

8 REPLIES 8
Highlighted
Resolver II
Resolver II

Re: CreateTable in Power Query

Hi @yogeshmaney 

 

Not sure to clearly understand your question but I am thinking you could Reference an existing query and apply the desired filters.

 

Inside Power Query Editor, right-click a query in the Queries pane (left side) and click "Reference".

It will create a new query (new table) dependant on the first one. Then you apply your filters as desired.

 

Let us know if that works for you.

 

Best

 

David

Highlighted
Helper I
Helper I

Re: CreateTable in Power Query

Thanks David. 

But referencing is Duplicating Data. I need to create a new Table by filtering rows.

Tried Table.RemoveRows but giving error

Highlighted
Resolver II
Resolver II

Re: CreateTable in Power Query

@yogeshmaney 

 

Can you provide some screenshots and examples of your current scenario and the desired output?

 

Best

 

David

Highlighted
Helper I
Helper I

Re: CreateTable in Power Query

Here's the sample

I have

Sr ItemLocation
1AUS
2BUK
3CUS
4DFR
5EUS

 

I want, A table for US  location 

Sr ItemLocation
1AUS
3CUS
5EUS

 

 

Highlighted
Resolver II
Resolver II

Re: CreateTable in Power Query

@yogeshmaney , have you tried Table.SelectRows()?

 

= Table.SelectRows(
  #"Previous step",
   each [Location] = "US"
)

 

Let us know if that works for you

 

Best

 

David 

Highlighted
Helper I
Helper I

Re: CreateTable in Power Query

Hi

I referenced DataSet &

Tried Following

 

let
Source = Data1,
#"Added Custom" = Table.AddColumn(Source, "Index", each if [Location] = "US" then "" else 0/1),
#"Changed Type" = Table.TransformColumnTypes(#"Added Custom",{{"Index", type binary}}),
#"Removed Errors" = Table.RemoveRowsWithErrors(#"Changed Type", {"Index"}),
#"Removed Columns" = Table.RemoveColumns(#"Removed Errors",{"Index"})
in
#"Removed Columns"

 

Its Working for me. 

View solution in original post

Highlighted
Resolver II
Resolver II

Re: CreateTable in Power Query

Great! Glad you found something that works for you @yogeshmaney 

 

I guess you could simplify that M code with:

let
Source = = Table.SelectRows(
   Data1,
   each [Location] = "US"
)
in Source

 

 

Best

 

David 

Highlighted
Helper I
Helper I

Re: CreateTable in Power Query

@David  That's Filtering Column. Data I am fetching is from Event Store. Each Referencing is around 750 MB . Need 20-25 such reference. And Making File heavy. Inside there are JSON blobs.

Deleting is the only option

Helpful resources

Announcements
Meet the 2020 Season 2 Power BI Super Users!

Meet the 2020 Season 2 Power BI Super Users!

Find out who's part of the program this season, and welcome the new Super Users.

August 2020 Community Challenge: Can You Solve These?

August 2020 Community Challenge: Can You Solve These?

We're excited to announce our first cross-community 'Can You Solve These?' challenge!

July 2020 Community Highlights

July 2020 Community Highlights

Learn about the exciting things that happened in July.

Featured Data Story of The Month

Featured Data Story of The Month

All Data Stories Gallery contributions are reviewed for each month. We select a contribution and feature the community member the following month.

Power BI Dev Camp - Developing with .NET Core

Power BI Dev Camp - Developing with .NET Core

Learn how to develop custom web applications for Power BI using .NET Core 3.1 and .NET 5.

Top Solution Authors
Top Kudoed Authors