• I tried to reproduce your problem by using DECLARE inside the query window in PowerBI (after you specify the database etc), and mine worked. Granted, my SQL was a lot simpler... so it's not the DECLARE that's causing the problem. I executed this inside that query window in PowerBi:

    DECLARE @NumRecords INT
    SET @NumRecords = 1+ABS(CHECKSUM(NEWID())%10);

    SELECT TOP (@NumRecords) *
    FROM dbo.SymptomData;

    and mine worked, so there's something else going on in there.  What happens if you execute your T-SQL inside SSMS? It works there, right?.