测试DAX计算与NBI [英] Testing DAX calculation with NBi

查看:309
本文介绍了测试DAX计算与NBI的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我做对我们的SSAS表格工程的自动化测试工具的一些研究。我发现NBI,认为这是真的很酷。我试图设置并成功运行一些基本的测试。然而,当我试图测试DAX计算,它说:功能未找到(见截图)。这听起来像它不支持SUM,但考虑到SUM是一个基本的功能,我会想象它应该工作。由于我是新来的这个工具,我想如果我做错了什么,仔细检查或只是什么错误是说...(不支持该功能)。

我回去和审查NBI文件,并将其提到看看他们NCAL.dll所有可用的前pression。不幸的是,我无法打开dll文件的可读版本。任何帮助是AP preciated。

下面的公式我想测试一下:

= SUMX(FILTER(MyTable的,AND(MyTable的[日期] = EARLIER(MyTable的[日期]),MyTable的[帐户] = EARLIER(MyTable的[帐户]))),MyTable的[金额])

在这里输入的形象描述

XML code(NBITS)文件

 <试验NAME =我的第二个测试:计算列相比,DAX公式>
  <系统-下试验>
   <执行与GT;
    <查询的connectionString =供应商= MSOLAP.7;数据源......>
     <![CDATA [
    评估
    SUMMARIZE(MyTable的,MyTable的[日期],MyTable的[帐户],MyTable的[金额],MyTable的[CalculatedAmount])
     ]]>
    < /查询>
   < /执行>
  < /系统下试验>
  <&断言GT;
    <评估-行>
      <可变列的索引=0>日期和LT; /变量>
      <可变列的索引=1>帐户< /变量>
      <可变列的索引=2>度< /变量>
      <可变列的索引=3> CalculatedAmount< /变量>
      <前pression列指数=3类型=数字容差=0.01> = SUMX(FILTER(MyTable的,AND(MyTable的[日期] = EARLIER(MyTable的[日期]),MyTable的[帐户] = EARLIER(MyTable的[帐户]))),MyTable的[金额])LT; / EX pression&GT ;
    < /评估,行>
  < /断言>
 < /试验>


解决方案

NBI支持查询中的标记,但不是在一个前pression标签DAX查询的评估。防爆pression和评估,行标签不是用来比较两个查询。为了实现这一目标,改变你的测试中使用的断言equalTo你的两个查询之间。这将是更容易,将工作。


  

我想一个更好的问题是我怎么测试测量和
  在确保其他开发人员不长期计算列
  无意中改变我进入时的计算/ EX pression
  设计表格模型?


我会回答三个层面:概念,逻辑和技术

在概念层面,你的测试是错误的:你永远不应该使用相同的实现你的主张,并在您的系统-下测试。这不是要specifc NBI或任何框架,但所有的自动化测试。测试的作用是不能保证别人不改变的东西,但保证的东西给出正确的结果。神器比较本身总是会导致一个绿色的测试,即使你的实现是错误的。在这种情况下,你必须用一个具体的静态结果,改变你的断言或者您需要创建导致数据库的同样的计算一个SQL语句或发现MDX另一个查询导致了同样的结果。

在逻辑层下面的句子是不正确的。


  

下面的公式我想测试一下:


您已经定义了这个公式在断言,而不是在你的系统下测试。这意味着,它是你正在测试不算什么,但是这是你引用(你是100%肯定它是正确的)。你正在测试是查询评估总结(MyTable的,MyTable的[日期],MyTable的[帐户],MyTable的[金额],MyTable的[CalculatedAmount])

在技术层面上,使用评价,行n工作是正确的选项。这种说法并不期待一个函数或查询,但基于行的变量的前pression(无DAX,没有SQL,...)。的使用 EARLIER 是一个明确的信号,这将是不可能的。在你的情况,你可能要比较两个查询的东西为:

 <&断言GT;
  < equalTo>
    <列索引=0的角色=键式=日期时间/>
    <列索引=1角色=键式=数字/>
    <列索引=2角色=值类型=数字/>
    <列索引=3角色=值类型=数字容差=0.01/>
    <&查询GT;
      EVALUATE总结(MyTable的,MyTable的[日期],MyTable的[帐户],MyTable的[金额],SUMX(FILTER(MyTable的,AND(MyTable的[日期] = EARLIER(MyTable的[日期]),MyTable的[帐户] = EARLIER(MyTable的[帐户]))),MyTable的[金额])
    < /查询>
  < / equalTo>
< /断言>

PS:我显然不是DAX的specilist,我不知道上面的查询是从一个语法点有效

I'm doing some research on automated test tool for our SSAS Tabular project. I found NBi and thought it is really cool. I attempted to set it up and successfully ran some basic tests. However, when I attempted to test dax calculation, it says "Function not found" (see screenshot). It sounds like it does not support SUM, but given that SUM is a basic function I would imagine it should work. Since I'm new to this tool, I wanted to double check if I've done something wrong or it is simply what the error is saying... (not supported function).

I went back and review NBi documentation and it mentioned to check out their NCAL.dll for all available expression. Unfortunately, I'm unable to open a readable version of that dll file. Any help is appreciated.

Here is the formula I want to test:

=SUMX(FILTER(MyTable, AND(MyTable[Date] = EARLIER(MyTable[Date]), MyTable[Account] = EARLIER(MyTable[Account]))), MyTable[Amount])

XML code (nbits) file

 <test name="My second test: Calculated column compared to DAX formula">
  <system-under-test>
   <execution>
    <query connectionString="Provider=MSOLAP.7;Data Source...">
     <![CDATA[    
    EVALUATE
    SUMMARIZE (MyTable, MyTable[Date], MyTable[Account], MyTable[Amount], MyTable[CalculatedAmount])
     ]]>
    </query>
   </execution>
  </system-under-test>
  <assert>
    <evaluate-rows>
      <variable column-index="0">Date</variable>
      <variable column-index="1">Account</variable>
      <variable column-index="2">Amount</variable>
      <variable column-index="3">CalculatedAmount</variable>
      <expression column-index="3" type="numeric" tolerance="0.01"> = SUMX(FILTER(MyTable, AND(MyTable[Date] = EARLIER(MyTable[Date]), MyTable[Account] = EARLIER(MyTable[Account]))), MyTable[Amount])</expression>
    </evaluate-rows>
  </assert>
 </test>

解决方案

NBi supports the evaluation of DAX queries in the query tag but not in an expression tag. Expression and evaluate-rows tags are not designed to compare two queries. To achieve this, change your test to use the assertion equalTo between your two queries. It will be easier and will work.

I guess a better question would be how do I test a measure and a calculated column in term of ensuring that another developer doesn't accidentally change the calculation/expression I entered when designing the Tabular model?

I'll answer at three levels: conceptual, logical and technical.

At the conceptual level, your test is wrong: you should never use the same implementation in your assertion and in your system-under-test. This is not specifc to NBi or to any framework but to all automated tests. The role of a test is not ensure that someone doesn't change something but to ensure that something gives the correct result. Comparing an artifact to itself will always result in a green test even if your implementation is wrong. In this case, you must change your assertion with a concrete static result or you need to create a sql statements resulting in the same calculation of your database or find another query in MDX resulting in the same result.

At the logical level the following sentence is not correct

Here is the formula I want to test:

You've defined this formula in your assert and not in your system-under-test. It means that it's not what you're testing but it's your reference (something you're 100% sure that it's correct). What you're testing is the query EVALUATE SUMMARIZE (MyTable, MyTable[Date], MyTable[Account], MyTable[Amount], MyTable[CalculatedAmount]).

At the technical level, using an evaluate-rows is nopt the correct option. This assertion is not expecting a function or a query but an expression based on row's variable (no DAX, no SQL, ...). The usage of EARLIER is a clear sign that it won't be possible. In your case, you must compare two queries probably something as:

<assert>
  <equalTo>
    <column index="0" role="key" type="dateTime"/>
    <column index="1" role="key" type="numeric"/>
    <column index="2" role="value" type="numeric"/>
    <column index="3" role="value" type="numeric" tolerance="0.01"/>
    <query>
      EVALUATE SUMMARIZE (MyTable, MyTable[Date], MyTable[Account], MyTable[Amount], SUMX(FILTER(MyTable, AND(MyTable[Date] = EARLIER(MyTable[Date]), MyTable[Account] = EARLIER(MyTable[Account]))), MyTable[Amount])
    </query>
  </equalTo>
</assert>

PS: I'm clearly not a specilist of DAX and I'm not sure the query above is valid from a syntax point of view.

这篇关于测试DAX计算与NBI的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆