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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
Santiago95
New Member

DAX table variables

For the last couple of weeks I`ve been trying to incorporate variables in DAX codes. However, I´ve struggled deepley when defining tables as variables. The main problem comes up when trying to reference an existing column from the table previously defined as a variable, it seems that this can´t be done. Lets look at the following code for the better understanding of the problem. (The formula used is LOOKUPVALUE):

 

Measure =


VAR Table_1= GROUPBY('Indice de estacionalidad';'Indice de estacionalidad'[Codigo];"MAX";MAXX(CURRENTGROUP();'Indice de estacionalidad'[Promedio anual]))
return


LOOKUPVALUE(


LOOKUPVALUE( ‘ Here we would need to reference a column from the table Tabla_1 ’; …. ; ….

 

(THE LANGUAGE USED IS SPANISH)

 

The example shown is very basic and variables should not be needed. However, this would be part of an even longer code, and defining tables as variable will make the code easier to read.

Another clear example would be instead of using LOOKUPVALUE, using ALL, were the columns of the virtual table cannot be accesed.

 

2 REPLIES 2
v-piga-msft
Resident Rockstar
Resident Rockstar

Hi @Santiago95,

 

Have you solved your problem?

 

If you have solved, please always accept the replies making sense as solution to your question so that people who may have the same question can get the solution directly.

 

If you still need help, please share some sample data and your desired output so that we could help further on it.

 

Best Regards,

Cherry

Community Support Team _ Cherry Gao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
AlexisOlson
Super User
Super User

Yeah, it's an annoying limitation. However, there are workarounds.

 

For example, if you want to look up the [Promedio anual] for a given [Codigo], say, 123, then you can access it like this:

 

MAXX(
    FILTER(Table_1, [Codigo] = 123),
    [Promedio anual]
)

There's only one row for that [Codigo], so the max will just be whatever is in that column.

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

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
Top Kudoed Authors