DAX - RANK功能

时间:2017-01-23 11:07:09

标签: mdx dax

我有一个来自WEBI的RANK代码,需要在DAX或MDX中编写类似的代码。两者都可以工作。但是DAX会更有用。

(defn string-place-typeII
  ""
  []
  (for [n (get-placetypes)]
    (calculate-distance-matrix 2 (define-context API-KEY) n))
  )

我在DAX中尝试过以下代码,但这并不是我需要的。

=Rank([OrderCount];([Category1];[Category2];[Category3])) 

你能帮我写类似的吗?

Grouping by Count. This is extra.

2 个答案:

答案 0 :(得分:1)

我不是很擅长DAX,但MDX方式如下:

<?php
if(isset($_POST['add']))
{
    $submit=$_POST['add'];
    $Name=$_POST['fname'];
    $Email=$_POST['email'];
    $Subject=$_POST['subject'];
    $Message=$_POST['message'];
    $dbhost='localhost';
    $dbnmae='someuser';
    $dbpass='somepassword';
    $conn = mysql_connect($dbhost,$dbnmae,$dbpass);
    if (!$conn) {
        die('Could not connect: '.mysql_error());
    }
    $sql="INSERT INTO mydb(name, email, subject, message)VALUES('$Name', '$Email', '$Subject', '$Message')";
    mysql_select_db('project1');
    $retrieval=mysql_query($conn,$sql);
    if(!$retrieval)
    {  die('Could not connect: '.mysql_error());
        }
        echo"Entered data successfully\n";
         mysql_close($conn);
}else   
    {   echo"something went to wrong";

    }

?>

DenseRank:

with
Dynamic Set OrderedSet as
Order(
    NonEmptyCrossJoin(
        [Dim Product].[Subcategory Name].[Subcategory Name].Members,
        [Dim Product].[Category Name].[Category Name].Members
        [Measures].[Order Quantity],
        2
    ),
    [Measures].[Order Quantity],
    BDESC
)

Member [Measures].[Rank] as
Rank(

        ([Dim Product].[Subcategory Name].Currentmember, 
        [Dim Product].[Category Name].Currentmember),
        OrderedSet
)

select 
{[Measures].[Order Quantity],[Measures].[Rank]} on 0,
non empty OrderedSet on 1
from 
[Adventure Works DW2016CTP3]

答案 1 :(得分:0)

以下是您问题的DAX指标:

Rank =
IF (
    HASONEVALUE ( YourTableName[ProductName] ),
    RANKX (
        ALL ( YourTableName ),
        CALCULATE ( SUM ( YourTableName[Order Quantity] ) ),
        ,
        ,
        DENSE
    )
)

IF(HASONEVALUE(YourTableName [ProductName])....部分将消除您的Grand Total显示1