How to format members Roles expressions? #1205
-
hi, I'm using in my scripts: FormatDax(Model.AllMeasures, true); But' obviously it doesn't works with the member's role expressions. Is it possible to do that? |
Beta Was this translation helpful? Give feedback.
Replies: 7 comments 3 replies
-
Hi @rvgfox This should give you what you need: List<string> messages = new List<string>();
// Run through all roles
foreach (var role in Model.Roles)
{
// Run through all tables to see if an RLS expression is set
foreach (var table in role.RowLevelSecurity.Keys)
{
if (!string.IsNullOrEmpty(role.RowLevelSecurity[table]))
{
// Format the DAX expression
role.RowLevelSecurity[table] = FormatDax(role.RowLevelSecurity[table]);
messages.Add($"Role {role.Name} - Table {table}");
}
}
}
if (messages.Count > 0)
{
Info("Formatted role expressions for:\r\n" + string.Join("\r\n", messages));
}
else
{
Info("Didn't find any role expressions to format!");
} Best Regards David - TE3 Support |
Beta Was this translation helpful? Give feedback.
-
Thank you very much @DBojsen it works perfectly. |
Beta Was this translation helpful? Give feedback.
-
Hi @rvgfox Here is a better script that works in both TE3 & TE2: List<string> messages = new List<string>();
// Run through all roles
foreach (var role in Model.Roles)
{
// Run through all table permissions
foreach (var permission in role.TablePermissions)
{
FormatDax(permission);
messages.Add("Role " + role.Name + " - Table " + permission.TableName);
}
}
if (messages.Count > 0)
{
Info("Formatted role expressions for:\r\n" + string.Join("\r\n", messages));
}
else
{
Info("Didn't find any role expressions to format!");
} |
Beta Was this translation helpful? Give feedback.
-
Thank you very much @DBojsen I've tested:
And now, in TE2 I haven't the error message, thanks. But I'm testing with this measure:
With TE3 it's formated to:
It's correct acording with BPA, but with TE2 it's formated to:
It doesn't follow the BP because "Measure references should not be qualified with the table name" Some ideas? |
Beta Was this translation helpful? Give feedback.
-
Hi @rvgfox TE3 uses our own formatting engine by default. |
Beta Was this translation helpful? Give feedback.
-
Thanks @DBojsen Will them use both, TE2 and TE3, the same engine in a near future? |
Beta Was this translation helpful? Give feedback.
-
Hi @rvgfox Sorry - your comment slipped through my holiday email madness. / David |
Beta Was this translation helpful? Give feedback.
Hi @rvgfox
This should give you what you need: