Skip to content

Commit

Permalink
v1.1.0
Browse files Browse the repository at this point in the history
Simplified dax string
  • Loading branch information
m-kovalsky authored Apr 13, 2021
1 parent 03e93d1 commit a526a1f
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions BlankRowFinder.cs
Original file line number Diff line number Diff line change
@@ -1,32 +1,33 @@
var sb = new System.Text.StringBuilder();
string newline = Environment.NewLine;

sb.Append("FromTable" + '\t' + "ToTable" + '\t' + "BlankRowCount");
sb.Append(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 fromColumn = r.FromColumn.Name;
string toTable = r.ToTable.Name;
string toColumn = r.ToColumn.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('"+fromTable+"'),ISBLANK('"+toTable+"'["+toColumn+"])))";
dax = "SUMMARIZECOLUMNS(\"test\",CALCULATE(COUNTROWS("+fromTableFull+"),ISBLANK("+toObject+")))";
}
else
{
dax = "SUMMARIZECOLUMNS(\"test\",CALCULATE(COUNTROWS('"+fromTable+"'),USERELATIONSHIP('"+fromTable+"'["+fromColumn+"],'"+toTable+"'["+toColumn+"]),ISBLANK('"+toTable+"'["+toColumn+"])))";
dax = "SUMMARIZECOLUMNS(\"test\",CALCULATE(COUNTROWS("+fromTableFull+"),USERELATIONSHIP("+fromObject+","+toObject+"),ISBLANK("+toObject+")))";
}

var daxResult = EvaluateDax(dax);
string blankRowCount = daxResult.ToString();

if (daxResult.ToString() != "Table")
if (blankRowCount != "Table")
{
sb.Append(fromTable + '\t' + toTable + '\t' + daxResult.ToString());
sb.Append(Environment.NewLine);
sb.Append(fromTable + '\t' + toTable + '\t' + blankRowCount + newline);
}
}

Expand Down

0 comments on commit a526a1f

Please sign in to comment.