Power BI-DAX不同数量

时间:2019-06-04 13:14:55

标签: powerbi dax tabular ssas-tabular

我对查询结果有疑问。

DEFINE
MEASURE 'Source'[DistinctCount] = DISTINCTCOUNT('Source'[Source])
MEASURE 'Allocation'[DistinctCountRows] =
    COUNTROWS ( FILTER ( VALUES ( Source[Source] ), COUNT('Allocation'[QUANTITY]) > 0 ) )
MEASURE 'Allocation'[AllocationNew] =   
IF(
    --ISFILTERED('Source'[Source]) && DISTINCTCOUNT('Source'[Source]) > 1
    COUNTROWS ( FILTER ( VALUES ( Source[Source] ), COUNT('Allocation'[QUANTITY])  > 0 ) ) > 1
    ,"N/A (multiple sources selected)"
    ,IF(
        COUNTROWS ( FILTER ( VALUES ( Allocation[LINEPACK_ALLOCATION_TYPE_ID] ), COUNT('Allocation'[QUANTITY]) > 0 ) ) > 1 && NOT ISBLANK('Allocation'[Allocation Count]),
        --DISTINCTCOUNT(Allocation[LINEPACK_ALLOCATION_TYPE_ID]) > 1 && NOT ISBLANK('Allocation'[Allocation Count]),
        "N/A (multiple allocation types selected)",
        SUM('Allocation'[QUANTITY])
   )
)
EVALUATE
SUMMARIZECOLUMNS
(
    Source[Source],
    "Sources", CALCULATE('Source'[DistinctCount])
    ,"Countrows of sources", CALCULATE('Allocation'[DistinctCountRows])
    ,"AllocationNew", CALCULATE('Allocation'[AllocationNew])
)

结果是:

enter image description here

当我在Source中添加评论时,结果是:

enter image description here

尽管所需结果为[源计数] = 1,并且[AllocationNew]应包含一个值。我想我快到了,但无法弄清楚出什么问题了。

0 个答案:

没有答案