Forum Discussion

smpa01's avatar
smpa01
Community Champion
1 year ago

TMSL equivalent in XMLA

Does XMLA has an equivalent of TMSL's createOrReplace?

 

I tried with Alter Element but it did not work.

 

bcdobbs  GilbertQ 

10 Replies

  • seems to be the same syntax.

     

    {
      "createOrReplace": {
        "object": {
          "database": "Opportunity Field History",
          "table": "Opportunities",
          "partition": "2014"
        },
        "partition": {
          "name": "2014",
          "mode": "import",
          "source": {
            "type": "policyRange",
            "start": "2014-01-01T00:00:00",
            "end": "2015-01-01T00:00:00",
            "granularity": "year"
          }
        }
      }
    }
    • smpa01's avatar
      smpa01
      Community Champion

      This is TMSL, I am looking for XMLA

       

      • lbendlin's avatar
        lbendlin
        Super User

        I thought so too but you can use that as is in your XMLA calls.

         

         

        Login-PowerBI
        $XmlaQuery = @"
        {
        "refresh": {
        "type": "automatic",
        "applyRefreshPolicy": true,
        "effectiveDate": "1/1/2024",
        "objects": [
        {
        "database": "Analyze in Excel",
        "table": "Details"
        }
        ]
        }
        }
        "@
        
        # URL is a relative or absolute URL of the Power BI entity to access. 
        $res=Invoke-PowerBIRestMethod -Url 'groups/xxx/datasets/yyy/refreshes' -Method Post -Body $XmlaQuery 
        

        etc.

  • If you script it out from SSMS it will be in the XML structure?

    • lbendlin's avatar
      lbendlin
      Super User

      No, that produces JSON. However that works well enough, so I don't really see the need to insist on XML.

    • smpa01's avatar
      smpa01
      Community Champion

      ssms does not have any ALTER to script that is equivalent to TMSL's createOrReplace.

      • lbendlin's avatar
        lbendlin
        Super User

        Please check further back in the thread. I provided just such an example. I selected an object and clicked the Script button.

  • Hi smpa01 

     

    As lbendlin said there is no XML format for the Semantic Models. They are stored in JSON or if using the newer format will now be TMSL.