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.
I am trying to execute my DAX Query from VBA code while passing in a date feild from a cell and it's running fine but the number of rows returned is getting truncated. When i run the same DAX query on DAX studio i get arounf 11k rows but the same query returns 6K rows on excel via VBA code. Any guidance on what's causing this would be appereciated.