1

I have a DAX variable that contains a table. How can I reference a particular column in that variable?

For example, in the below command, the EVALUATE returns an error. But it works if I replace table1 with FactInternetSales (which is the name of the table which contains that column)

define var table1=FactResellerSales
EVALUATE ROW("a",COUNTBLANK(table1[SalesAmount]))
explorer
  • 11
  • 1
  • 2

2 Answers2

1

In DAX you can't use a variable name as with tables that are defined in the model. What you can do is to use the original table names using the table variable as a filter. For instance like in the following code

DEFINE
    VAR tv1 =
        FILTER( Tab1, Tab1[F1] = "A" )
EVALUATE
ROW( "a", CALCULATE( COUNTBLANK( Tab1[Value] ), tv1 ) )
sergiom
  • 159
  • 4
0

In your DEFINE statement, use TABLE instead of VAR. Although a variable expression can contain a table, its usage isn't the same as an actual query table.

DEFINE
    TABLE table1 = FactResellerSales
EVALUATE
    ROW("a", COUNTBLANK(table1[SalesAmount]))

DEFINE DAX Statement

TABLE DAX Statement

solutionist
  • 351
  • 2
  • 6