Forum Discussion

RoySampad's avatar
RoySampad
Frequent Visitor
4 months ago
Solved

VBA support (to pass cell value as a dax filter) needed to pull data from power bi to excel

VBA support (to pass cell value as a dax filter) needed to pull data from power bi to excel
  • V-yubandi-msft's avatar
    V-yubandi-msft
    4 months ago

    Thank you for providing the complete VBA code. The discrepancy in row counts isn’t due to the DAX query itself DAX Studio returns all 11k rows but rather how Excel processes the ADODB recordset. By default, a forward-only cursor may stop early and not return all results.

     

    A common fix is to adjust the recordset properties before opening, for example

    rs.CursorLocation = 3   ' adUseClient
    rs.CursorType = 1       ' adOpenKeyset
    rs.LockType = 1         ' adLockReadOnly
    rs.MaxRecords = 0       ' no row limit
    

    Additionally, ensure that .CopyFromRecordset isn’t restricted by MaxRows. You can refer to Microsoft’s documentation here: Range.CopyFromRecordset method (Excel) | Microsoft Learn

    These adjustments are often suggested when importing larger datasets into Excel and should help you retrieve the full 11k rows from your Power BI dataset.

     

    Please adjust these settings on your side and let us know how it works. If anything seems unclear or if I’ve misunderstood, just let us know.