Forum Discussion
VBA support (to pass cell value as a dax filter) needed to pull data from power bi to excel
- 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 limitAdditionally, 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.
This should point you in the right direction
Update queries in Excel using VBA - Stack Overflow
Alternatively you can run the entire query from VBA.
excel - VBA Reptitive MDX query to Analysis Services - Stack Overflow