将状态为“可用”的产品数量求和,然后除以状态为“可用”的产品总数之和

SUM the amount of products with Available status and divide it by the sum of total products with the status Available

我有以下架构:

我正在使用与此 SSAS 表格多维数据集的实时连接,我想计算状态 = 可用的产品数量

每个产品与 Status=Available 的产品总数相比。

dax 查询如下:

Montant =
VAR MontantA = 
    CALCULATE ( 
        SUM(FactTable[montant]),
                 
        dim_status[labelstatus] = "Available" ,
        FactTable[ProductSK] <> -1

)
    )

VAR MontantTotal = 
    CALCULATE (
    SUM(FactTable[montant]),
        dim_status[labelstatus] = "Available" 
    )
RETURN
    DIVIDE ( 
        MontantA,
        MontantTotal
    )

我所有产品的结果都是 1。

我认为这可能会让您更接近您所追求的目标:

Montant =
VAR MontantA =
    CALCULATE (
        SUM ( FactTable[montant] ),
        dim_status[labelstatus] = "Available",
        KEEPFILTERS ( dim_product[ProductSK] <> -1 )
    )
VAR MontantTotal =
    CALCULATE (
        SUM ( FactTable[montant] ),
        dim_status[labelstatus] = "Available",
        ALL ( dim_product )
    )
RETURN
    DIVIDE ( MontantA, MontantTotal )