Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago
Solved

The expression specified in the query is not a valid table expression

Hi, please I am using table variable and when i call the table name "evaluate tbl "with evaluate it works but when I use it in the context of countrows it returns the error above

*

DEFINE
VAR fsumX =
SUMMARIZE(CHA,[Employee],[YearNo],[Organisation],[MonthNamed],
"CallTimeDuration",SUM(CHA[CallTimeDuration])
)
VAR tbl =
FILTER(
fsumX, 
[AvgDBanding] = "Less Than 60 Min(s)" && CHA,[Organisation] = "b" && CHA,[MonthNamed] ="November"
          )

EVALUATE

COUNTROWS(tbl)
//tbl

*

I saw a similar solution that works with countrows (https://social.msdn.microsoft.com/Forums/sqlserver/en-US/42325576-064d-4fbf-bc1c-12fbd6c89728/dax-columns-in-table-variables-cannot-be-referenced-via-tablenamecolumnname-syntax?forum=sqlanalysisservices) but i could not get the quey for mine.

I will appreciate a guide on this

 

Thanks

  • Anonymous's avatar
    Anonymous
    6 years ago

    Sorry, I thought your problem was in PBI.

     

    In Dax Studio you need to use the following to check the result of a measure:

    return
    ROW("Result:", COUNTROWS(tbl))


     

     

     

7 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi, 

     

    When I try to run the code I get an error on [AvgDBanding] does not exist. 

    When you add [AvgDBanding] to the FsumX / Summarize function then it will probably work.

    It does work for me either as a calculated table or as a measure (with countrows, of course), but I tested it with a very simple test set.

    Regards,

     

     

     

     

    • Anonymous's avatar
      Anonymous
      Not applicable

      Thanks for the response, the  return works well for me as well, but the "countrows" function on the tbl does not work, I was using the code in dax studio and it was throwing the error, but when I executed the code (countrows)in on power bi it worked, so I am guessing am missing something 

      • Anonymous's avatar
        Anonymous
        Not applicable

        Sorry, I thought your problem was in PBI.

         

        In Dax Studio you need to use the following to check the result of a measure:

        return
        ROW("Result:", COUNTROWS(tbl))