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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
rpereirait
New Member

Help on DAX : SELECTCOLUMNS equivalent to a SQL SUBSELECT?

Hi!

 

I need a help on my DAX Query. Below is my query that I'm using on a Tabular Model to pull Cost Center data. It's working perfectly.

 

EVALUATE (

DISTINCT(

FILTER(
SELECTCOLUMNS(
'dimensionCostCenter',
"Cost Center Code",'dimensionCostCenter'[Cost Center Code],
"Cost Center Name",'dimensionCostCenter'[Cost Center Name],
"Division Name",'dimensionCostCenter'[Division Name],
"Profit Center",'dimensionCostCenter'[Profit Center],
"Cost Center Roll Up L1 Name",'dimensionCostCenter'[Cost Center Roll Up L1 Name])
,NOT ([Cost Center Code]) IN {"211189","211193"})
)

)

 

My challenge is, somehow, to pull just one column, which would be the equivalent of a subselect in SQL.
I applied a pre-filter, to bring only the necessary codes. I'll still need to apply some more filters with the other columns, that's why I'm keeping these columns in the initial query.

But my expectation will be just bring in the "final select" only the Cost Center Code.

 

I appreciate your help!

3 REPLIES 3
Anonymous
Not applicable

SELECTCOLUMNS in DAX is a projection function, has nothing in common with SQL's subselect. www.dax.guide/selectcolumns 

Greg_Deckler
Super User
Super User

@rpereirait Just wrap another SELECTCOLUMNS statement around what you already have?


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Hi @Greg_Deckler , I haven't tried a new SELECTCOLUMNS around what I'm already have yet, but I'll. Any ideas on what I could put in the table declaration, since the selectcolumns syntax asks me to do that? SELECTCOLUMNS(<table>, <name>, <scalar_expression> [, <name>, <scalar_expression>]…)

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors