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):
VAR Table_1= GROUPBY('Indice de estacionalidad';'Indice de estacionalidad'[Codigo];"MAX";MAXX(CURRENTGROUP();'Indice de estacionalidad'[Promedio anual]))
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.
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.
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.