Object Level Security update using TMLS on the power bi service dataset

69 views Asked by At

I am trying to set the object level security of an table in my power bi service dataset to none using TMSL. Below mentioned MS doc says it could done with basic TMSL command. But it throws error saying "Data at root level is invalid"

    "roles": [
      {
        "name": "My Role",
        "description": "All allowed users to query the model",
        "modelPermission": "read",
        "tablePermissions": [
          {
            "name": "My Table",
            "metadataPermission": "none"
          }
        ]
      }
]

I also tried to put it in the alter command like below, it returns empty but still does not impact the dataset

    {
"alter": {
"object": {
"database": "dataset name",
"role":"Role Name"
},
"role":
{
"name": "Role Name",
"description": "All allowed users to query the model",
"modelPermission": "read",
"tablePermissions": [
{
"name": "Table Name",
"metadataPermission": "none"
}
]
}

}
}

https://learn.microsoft.com/en-us/analysis-services/tabular-models/object-level-security?view=asallproducts-allversions#column-level-security

Please suggest what am i missing.

1

There are 1 answers

0
TheRizza On

For a whole table, you can do this in Power BI Desktop without TMSL.

Modeling > Manage roles > Create (My role) > ... on table > Add filter... > Hide all rows

enter image description here

Then if I view what this did, I can see the correct TMSL for a whole table is "filterExpression": "false":

{
  "createOrReplace": {
    "object": {
      "database": "1108a63c-my-GUID",
      "role": "My role"
    },
    "role": {
      "name": "My role",
      "modelPermission": "read",
      "tablePermissions": [
        {
          "name": "Country Flags",
          "filterExpression": "false"
        }
      ],
      "annotations": [
        {
          "name": "PBI_Id",
          "value": "de68488607"
        }
      ]
    }
  }
}