簡體   English   中英

Power BI - 帶度量的動態表

[英]Power BI - Dynamic Table with Measure

我有一個這樣的數據集

患者姓名 年齡 性別 測試結果
亞歷克斯 48歲 積極的
35 消極的
迪維亞 45 F 積極的

在我的 Power BI Dashboard 中,我需要顯示一個自由表格,如下所示

商品描述 價值
測試結果呈陽性的成年男性患者總數 1252
測試結果呈陽性的成年女性患者總數 856
陽性百分比 2.8

我已經為計算創建了度量。 我試圖創建一個帶有度量的自定義表,但它們沒有動態變化。 當切片器選擇的值發生變化時,該表僅顯示 static 個值。 有沒有更好的方式來呈現這個?

謝謝你,NSR

你在你的措施中嘗試ALLSELECTED嗎?

Total number of Adult-Male Patients with Positive Test Result =
CALCULATE (
    COUNT ( 'Table'[test_result] ),
    FILTER (
        ALLSELECTED ( 'Table' ),
        'Table'[test_result] = "positive"
            && 'Table'[gender ] = "m"
            && 'Table'[age ] > 18
    )
)

首先創建一個空表

    let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i44FAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Item Description" = _t, Value = _t])
in
    Source

然后我們將通過創建一個表來用你的措施填充這個表......

建模 --> 新表

    Report Table =
UNION (
    Report,
    ROW (
        "Item Description", "Total number of Adult-Male Patients with Positive Test Result",
        "Value",
            CALCULATE (
                COUNT ( 'Table'[test_result] ),
                FILTER (
                    ALLSELECTED ( 'Table' ),
                    'Table'[test_result] = "positive"
                        && 'Table'[gender ] = "m"
                        && 'Table'[age ] > 18
                )
            )
    ),
    ROW (
        "Item Description", "Total number of Female-Male Patients with Positive Test Result",
        "Value",
            CALCULATE (
                COUNT ( 'Table'[test_result] ),
                FILTER (
                    ALLSELECTED ( 'Table' ),
                    'Table'[test_result] = "positive"
                        && 'Table'[gender ] = "f"
                        && 'Table'[age ] > 18
                )
            )
    ),
    ROW (
        "Item Description", "Percentage Positive",
        "Value",
            FORMAT (
                DIVIDE (
                    CALCULATE (
                        COUNT ( 'Table'[test_result] ),
                        FILTER (
                            ALLSELECTED ( 'Table' ),
                            'Table'[test_result] = "positive"
                                && 'Table'[age ] > 18
                        )
                    ),
                    CALCULATE ( COUNT ( 'Table'[test_result] ), ALL ( 'Table' ) )
                ),
                "Percent"
            )
    )
)

結果

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM