-
Notifications
You must be signed in to change notification settings - Fork 60
/
BlankRowFinder.cs
34 lines (28 loc) · 1.06 KB
/
BlankRowFinder.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
var sb = new System.Text.StringBuilder();
string newline = Environment.NewLine;
sb.Append("FromTable" + '\t' + "ToTable" + '\t' + "BlankRowCount" + newline);
foreach (var r in Model.Relationships.ToList())
{
bool act = r.IsActive;
string fromTable = r.FromTable.Name;
string toTable = r.ToTable.Name;
string fromTableFull = r.FromTable.DaxObjectFullName;
string fromObject = r.FromColumn.DaxObjectFullName;
string toObject = r.ToColumn.DaxObjectFullName;
string dax;
if (act)
{
dax = "SUMMARIZECOLUMNS(\"test\",CALCULATE(COUNTROWS("+fromTableFull+"),ISBLANK("+toObject+")))";
}
else
{
dax = "SUMMARIZECOLUMNS(\"test\",CALCULATE(COUNTROWS("+fromTableFull+"),USERELATIONSHIP("+fromObject+","+toObject+"),ISBLANK("+toObject+")))";
}
var daxResult = EvaluateDax(dax);
string blankRowCount = daxResult.ToString();
if (blankRowCount != "Table")
{
sb.Append(fromTable + '\t' + toTable + '\t' + blankRowCount + newline);
}
}
sb.Output();