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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
antotom
Frequent Visitor

Dynamic referencing of a column

Hello there,

 

I need to exclude the 0s from a column, but I have a problem referencing it.

 

Basically, I would need to exclude the 0s from Column “082022” (August 2022), and I'm doing it with this line of code:

= Table.SelectRows(#"Removed Other Columns", each ([202208] <> 0))

 

The problem is that the name of the column can change, it’s not always “082022”. In this regard, that name is coming from a previous step, in which I managed to retrieve the name of the last column in my data set, and I defined it as “LastCol”, with the following steps:

 

= Table.DemoteHeaders(Source)

= Table.Transpose(#"Demoted Headers")[Column1]

= List.LastN(#"Transposed Table", 4)

= #"Kept Bottom Items"{0}

 

The last step returned me indeed 082022, so my LastCol, but how can I reference it when I filter the column?

I tried using: = Table.SelectRows(#"Removed Other Columns", each (#"LastCol" <> 0))

 

But the filter doesn’t work, I don't get an error but the 0s are not filtered out.

 

Does anybody have any idea about how to do this please?

1 ACCEPTED SOLUTION
jgordon11
Resolver II
Resolver II

try

 

= Table.SelectRows(#"Removed Other Columns", each Record.Field(_, LastCol) <> 0)

View solution in original post

2 REPLIES 2
jgordon11
Resolver II
Resolver II

try

 

= Table.SelectRows(#"Removed Other Columns", each Record.Field(_, LastCol) <> 0)

You got it, thanks a lot! 🙂

Helpful resources

Announcements
Fabcon_Europe_Social_Bogo

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

Power BI Carousel June 2024

Power BI Monthly Update - June 2024

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

PBI_Carousel_NL_June

Fabric Community Update - June 2024

Get the latest Fabric updates from Build 2024, key Skills Challenge voucher deadlines, top blogs, forum posts, and product ideas.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

Top Solution Authors
Top Kudoed Authors