数据模型是否始终随Power Query的刷新一起刷新,并且仅在Power Query刷新完成后启动?

Does Data Model always refresh along with the refresh of Power Query and only start after Power Query refresh is complete?

提问人:MZN001 提问时间:11/3/2023 最后编辑:egleaseMZN001 更新时间:11/3/2023 访问量:15

问:

我想确认数据模型是否会与查询刷新一起刷新,即使我们从未打开 Power Pivot UI,并且仅在查询刷新完成后才开始

这是我当前的VBA代码来触发PQ刷新,

Sub RefreshAll()

'Disable background refresh

Dim lCnt As Long

With ActiveWorkbook
    For lCnt = 1 To .Connections.Count

        If .Connections(lCnt).Type = xlConnectionTypeOLEDB Then
            .Connections(lCnt).OLEDBConnection.BackgroundQuery = False
        End If
        
    Next lCnt

End With


'Start refreshing all
Dim i As Integer


'Section for Queries
Dim queryNames(1 To 3) As String
Dim queryName As Variant

queryNames(1) = "Query - Dummy_1"
queryNames(2) = "Query - Dummy_2"
queryNames(3) = "Query - Dummy_3"


For Each queryName In queryNames

ThisWorkbook.Connections(queryName).Refresh
DoEvents

Next queryName

我想知道我是否需要在旁边添加以下代码,以确保我的数据模型在 PQ 刷新完成后会相应地使用最新数据进行刷新,我担心数据模型在 PQ 刷新完成后不会跟进或在 PQ 刷新完成之前开始刷新(这是我感到困惑的地方)

'Section for Data Models (I am not sure if I need to add this section)
Dim datamodelNames(1 To 3) As String
Dim datamodelName As Variant

datamodelNames(1) = "Dummy_1"
datamodelNames(2) = "Dummy_2"
datamodelNames(3) = "Dummy_3"


For Each datamodelName In datamodelNames

ThisWorkbook.Model.ModelTables(datamodelName).Refresh
DoEvents

Next datamodelName

谢谢大家!! MZ的

如上所述。我不确定数据模型是否会在 PQ 刷新完成后刷新,或者在不捕获完成的 PQ 刷新的情况下一起启动(这两种情况都会导致我的 Power Pivot 数据不准确)

Excel PowerQuery PowerPivot 数据模型

评论


答: 暂无答案