Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The name 'EvaluateDax' does not exist in the current context #44

Closed
samaguire opened this issue Jun 6, 2021 · 1 comment
Closed

The name 'EvaluateDax' does not exist in the current context #44

samaguire opened this issue Jun 6, 2021 · 1 comment
Labels
issue: bug Confirmed as a bug in TE3
Milestone

Comments

@samaguire
Copy link

I get the error message as per the title for EvaluateDax or ExecuteDax when running code like the below. Code works in TE2.

EvaluateDax

// https://github.com/microsoft/Analysis-Services/tree/master/BestPracticeRules

int maxLen = 100;
string annName = "LongLengthRowCount";

foreach (var c in Model.AllColumns.Where(a => a.DataType == DataType.String))
{
    string tableName = c.Table.Name;
    string columnName = c.Name;
    
    var obj = Model.Tables[tableName].Columns[columnName];
    var result = EvaluateDax("SUMMARIZECOLUMNS(\"test\",CALCULATE(COUNTROWS(DISTINCT('"+tableName+"'["+columnName+"])),LEN('"+tableName+"'["+columnName+"]) > "+maxLen+"))");
    
    obj.SetAnnotation(annName,result.ToString());
    
    if (obj.GetAnnotation(annName) == "Table")
    {
        obj.SetAnnotation(annName,"0");
    }
}

ExecuteDax

// https://github.com/microsoft/Analysis-Services/tree/master/BestPracticeRules

// Split Date/Time recommendation
string annName = "DateTimeWithHourMinSec";
foreach (var c in Model.AllColumns.Where(a => a.DataType == DataType.DateTime))
{
    string columnName = c.Name;
    string tableName = c.Table.Name;
    var obj = Model.Tables[tableName].Columns[columnName];
    
    var result = ExecuteDax("EVALUATE TOPN(5,SUMMARIZECOLUMNS('"+tableName+"'["+columnName+"]))").Tables[0];

    for (int r = 0; r < result.Rows.Count; r++)
    {
        string resultValue = result.Rows[r][0].ToString();
        if (!resultValue.EndsWith("12:00:00 AM"))
        {
            obj.SetAnnotation(annName,"1");
            r=50;
        }
        else
        {
            obj.SetAnnotation(annName,"0");
        }
    }
}
@otykier otykier added the issue: bug Confirmed as a bug in TE3 label Jun 8, 2021
@otykier otykier added this to the 3.0.6 milestone Jun 16, 2021
@otykier
Copy link
Collaborator

otykier commented Jun 17, 2021

Fixed in 3.0.6.

@otykier otykier closed this as completed Jun 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
issue: bug Confirmed as a bug in TE3
Development

No branches or pull requests

2 participants