DAX Studio - Expression specified in the query is not a valid table expression

155 views Asked by At

I have a code and outcome as below

EVALUATE
VAR AggregatedSalesInCurrency =
ADDCOLUMNS (
SUMMARIZE(
    'OPC SUMMARY (2)',
    'Calendar'[Date],
    'dimCurrency'[Currency Code]

),

        "@SalesAmountInCurrency", [Sales (Internal)],
        
        "@Rate", CALCULATE ( 
                 SELECTEDVALUE ( 'factFX'[FX Rate] )
        )
    )
RETURN
AggregatedSalesInCurrency

outcome table

But if I add the SUMX function say the expression specified in the query is not a valid table expression why would that be? many thanks in advance.

   EVALUATE
VAR AggregatedSalesInCurrency =
ADDCOLUMNS (
SUMMARIZE(
    'OPC SUMMARY (2)',
    'Calendar'[Date],
    'dimCurrency'[Currency Code]

),

        "@SalesAmountInCurrency", [Sales (Internal)],
        
        "@Rate", CALCULATE ( 
                 SELECTEDVALUE ( 'factFX'[FX Rate] )
        )
    )
//RETURN
//AggregatedSalesInCurrency


VAR Result =
    SUMX (
        AggregatedSalesInCurrency,
        [@SalesAmountInCurrency] / [@Rate]
    )
RETURN
    Result
    
1

There are 1 answers

1
davidebacci On BEST ANSWER

You're in DAX Studio and so need to return a table. Try wrapping your return in curly braces.

RETURN
    {Result}