Forum Discussion

jaryszek's avatar
jaryszek
Icon for Super User rankSuper User
1 year ago
Solved

How to move entire Measure Table in Datalake On OneLake?

Hello, I want to move all measures in my Measure table into OneLake model from Import Mode report. how to do this without using Semantic Labs? Best, Jacek
  • DataNinja777's avatar
    1 year ago

    Hi jaryszek ,

     

    Yes, you can absolutely move an entire measure table from a Power BI Import Mode report to a OneLake model without Semantic Link. The most common methods involve using external tools or the DAX Query View feature within Power BI Desktop.

     

    One of the most efficient ways is by using Tabular Editor. You would start by opening two instances of Tabular Editor. Connect the first instance to your local Power BI Desktop file and the second instance to your Direct Lake semantic model using its XMLA endpoint. In the instance connected to your local file, navigate to your measure table, select all the measures you wish to move, and copy them. Then, switch to the instance connected to your Direct Lake model, select the destination table, and simply paste the measures. After pasting, save the changes back to the Power BI service to finalize the process.

     

    Alternatively, you can use the DAX Query View directly within Power BI Desktop. First, open the Import Mode report that contains your measures. Switch to the DAX Query View, find your measure table in the Data pane, right-click it, and select "Define all measures in this table." This action will generate a DAX script containing the definitions for all the measures in that table.

    DEFINE
      TABLE 'YourMeasureTableName' =
        ADDCOLUMNS(
          KEEPFILTERS(
            FILTER(
              VALUES('YourMeasureTableName'[Measure]),
              NOT(ISBLANK('YourMeasureTableName'[Measure]))
            )
          ),
          "Expression",
          VAR vMeasure = 'YourMeasureTableName'[Measure]
          RETURN
            SWITCH(
              vMeasure,
              "Total Sales", [Total Sales],
              "Sales YTD", [Sales YTD],
              "Profit Margin", [Profit Margin]
              // ... and so on for all your measures
            )
        )
    
    EVALUATE
      'YourMeasureTableName'

    Copy this entire generated script. Next, open a new Power BI Desktop file and create a live connection to your Direct Lake semantic model. Go to the DAX Query View in this new file, paste the script you copied, and run it. This will create all the measures in your Direct Lake model. Remember to save and publish the file to apply the changes in the service.

     

    For a more automated, code-driven solution, you can use PowerShell. This advanced method involves saving your .pbix file as a .pbit template, renaming it to a .zip file, and extracting its contents. Inside, you'll find the DataModelSchema JSON file, which contains all the model metadata. You can write a PowerShell script to parse this JSON file to extract the measure names and their DAX expressions. Finally, using the Tabular Object Model (TOM) library in PowerShell, you can connect to your Direct Lake model and programmatically create each of the extracted measures.

     

    Best regards,