统计表中的行数
脚本用途
如果你想查看某个表加载了多少行,或快速检查该表是否根本已加载。此脚本需要连接到远程模型,或通过工作区模式进行连接。
脚本
统计所选表中的行数
// This script counts rows in a selected table and displays the result in a pop-up info box.
// It does not write any changes to this model.
//
// Use this script when you want to check whether a table was loaded or how many rows it has.
//
// Get table name
string _TableName =
Selected.Table.DaxObjectFullName;
// Count table rows
string _dax =
"{ FORMAT( COUNTROWS (" + _TableName + "), \"#,##0\" ) }";
// Evaluate DAX
string _TableRows =
Convert.ToString(EvaluateDax( _dax ));
// Return output in pop-up
Info ( "Number of rows in " + _TableName + ": " + _TableRows);
说明
此代码片段会遍历模型并统计不同对象类型的数量,然后以手动构建的分层“节点和树”格式显示出来。你可以将其注释掉
输出示例
