Forum Discussion
migration data model from AS to Power BI
- 8 years ago
Hi Anonymous,
I'm afraid we can't do that for now. But I found a workaround indeed. The measures in an Excel model can be imported into PBI Desktop. And we can use VBA to create measures fastly. The workaround is clear now. Please try the demo in the attachment.
1. Install the DAX studio from here.
2. Connect to the SSAS tabular and run the query below.
select [name], [expression] from $SYSTEM.TMSCHEMA_MEASURES
3. Now, we get all the measure names and their details (part 5 in the image). Copy the details to a workbook in sheet1 starting from cell A1.
4. Copy a few cells in a sheet and create a very simple data model in Excel.
5. Open the Visual Basic window and paste the code below and run it.
Public Sub add_measure() Dim Mdl As Model Dim tbl As ModelTable Dim nRows As Integer Dim i As Integer Dim measureName As String Dim measureContent As String Set Mdl = ActiveWorkbook.Model Set tbl = Mdl.ModelTables(1) nRows = Sheet1.UsedRange.Rows.Count 'get the total rows For i = 1 To nRows measureName = Sheet1.Cells(i, 1) measureContent = Sheet1.Cells(i, 2) ' MsgBox measureName ' MsgBox measureContent Mdl.ModelMeasures.Add measureName, tbl, measureContent, Mdl.ModelFormatWholeNumber(1) 'insert a measure to the model Next i End Sub6. Now, we can see all the measures in the model and we can import all of them into Desktop.
Best Regards,
Dale
Hi Anonymous,
I'm afraid we can't do that for now. But I found a workaround indeed. The measures in an Excel model can be imported into PBI Desktop. And we can use VBA to create measures fastly. The workaround is clear now. Please try the demo in the attachment.
1. Install the DAX studio from here.
2. Connect to the SSAS tabular and run the query below.
select [name], [expression] from $SYSTEM.TMSCHEMA_MEASURES
3. Now, we get all the measure names and their details (part 5 in the image). Copy the details to a workbook in sheet1 starting from cell A1.
4. Copy a few cells in a sheet and create a very simple data model in Excel.
5. Open the Visual Basic window and paste the code below and run it.
Public Sub add_measure()
Dim Mdl As Model
Dim tbl As ModelTable
Dim nRows As Integer
Dim i As Integer
Dim measureName As String
Dim measureContent As String
Set Mdl = ActiveWorkbook.Model
Set tbl = Mdl.ModelTables(1)
nRows = Sheet1.UsedRange.Rows.Count 'get the total rows
For i = 1 To nRows
measureName = Sheet1.Cells(i, 1)
measureContent = Sheet1.Cells(i, 2)
' MsgBox measureName
' MsgBox measureContent
Mdl.ModelMeasures.Add measureName, tbl, measureContent, Mdl.ModelFormatWholeNumber(1) 'insert a measure to the model
Next i
End Sub
6. Now, we can see all the measures in the model and we can import all of them into Desktop.
Best Regards,
Dale
Thanks Dale,
The workaround works. Really appreciate your help.