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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
Anonymous
Not applicable

is there a way to filter a table by a column added to it in a single expression

Hey guys, is there a way to perform this sort of operation?:

New Table = 
VAR crossjoinedAB = CROSSJOIN('tableA', 'tableB'
VAR crossjoinedABwithNewCol = AddColumn(crossjoinedAB, "FilterByThisColumn", IF( [ColumnInA] = 1, 1, 0))
RETURN CALCULATETABLE(crossjoinedABwithNewCol, [FilterByThisColumn] = 1)

As of right now I cannot get away with adding a new column, and then filtering by it in the same expression. I can get around this by splitting this into two parts, where part 1 makes the table with the new column

New Table = 
VAR crossjoinedAB = CROSSJOIN('tableA', 'tableB'
VAR crossjoinedABwithNewCol = AddColumn(crossjoinedAB, "FilterByThisColumn", IF( [ColumnInA] = 1, 1, 0))

and part 2, is when I make ANOTHER new table to filter it.

New Table2 = 
RETURN CALCULATETABLE('New Table', [FilterByThisColumn] = 1)

Is there a way to do this in a single step, without having to create an intermediary table?

1 ACCEPTED SOLUTION
mwegener
Most Valuable Professional
Most Valuable Professional

Hi @Anonymous ,

 

try this

New Table = 
VAR crossjoinedAB = CROSSJOIN('tableA', 'tableB')
VAR crossjoinedABwithNewCol = ADDCOLUMNS(crossjoinedAB, "FilterByThisColumn", IF( [ColumnInA] = 1, 1, 0))
RETURN FILTER(crossjoinedABwithNewCol, [FilterByThisColumn] = 1)
Did I answer your question?
Please mark my post as solution, this will also help others.
Please give Kudos for support.

Marcus Wegener works as Full Stack Power BI Engineer at BI or DIE.
His mission is clear: "Get the most out of data, with Power BI."
twitter - LinkedIn - YouTube - website - podcast - Power BI Tutorials


View solution in original post

6 REPLIES 6
mwegener
Most Valuable Professional
Most Valuable Professional

Hi @Anonymous ,

 

why don't you use power query for transformation?

 

Did I answer your question?
Please mark my post as solution, this will also help others.
Please give Kudos for support.

Marcus Wegener works as Full Stack Power BI Engineer at BI or DIE.
His mission is clear: "Get the most out of data, with Power BI."
twitter - LinkedIn - YouTube - website - podcast - Power BI Tutorials


Anonymous
Not applicable

I already have this transformation up and running through power query, I'm just trying to recreate it for testing which loads faster. 

mwegener
Most Valuable Professional
Most Valuable Professional

Hi @Anonymous ,

 

try this

New Table = 
VAR crossjoinedAB = CROSSJOIN('tableA', 'tableB')
VAR crossjoinedABwithNewCol = ADDCOLUMNS(crossjoinedAB, "FilterByThisColumn", IF( [ColumnInA] = 1, 1, 0))
RETURN FILTER(crossjoinedABwithNewCol, [FilterByThisColumn] = 1)
Did I answer your question?
Please mark my post as solution, this will also help others.
Please give Kudos for support.

Marcus Wegener works as Full Stack Power BI Engineer at BI or DIE.
His mission is clear: "Get the most out of data, with Power BI."
twitter - LinkedIn - YouTube - website - podcast - Power BI Tutorials


mwegener
Most Valuable Professional
Most Valuable Professional

Hi @Anonymous ,

 

from experience I would say Power Query.
Power Query has the advantage that with query folding, the data may already be filtered in the source and that the result is saved with a higher compression.

 

Did I answer your question?
Please mark my post as solution, this will also help others.
Please give Kudos for support.

Marcus Wegener works as Full Stack Power BI Engineer at BI or DIE.
His mission is clear: "Get the most out of data, with Power BI."
twitter - LinkedIn - YouTube - website - podcast - Power BI Tutorials


Anonymous
Not applicable

I understand that may be true, but I would still prefer to have an answer to my original question. 

Anonymous
Not applicable

sorry, you provided the answer just as I responded to your previous post

Helpful resources

Announcements
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!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

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