[英]How can I report on the number of people in more than one category?
我在 Power BI 中有一個表格,其中包含有關我們組織支持的人員的信息。 我們提供多種不同的服務,用戶可以在給定的時間段內訪問其中一項或多項服務。
我的表如下所示:
從這里我們可以看到,序列號為 102617 的用戶在 2020 年 1 月訪問了兩項服務(社區服務和發布)。
我需要報告有多少人得到了多項服務的支持。 output 應如下所示:
我對 DAX 相當陌生,我知道我需要一個度量,因為它需要在當前過濾器上下文中計算(按日期范圍過濾)。
我已經嘗試了以下代碼,它讓我成為了其中的一部分。
Total = SUMX( VALUES(Supported[SERIALNUMBER]), CALCULATE(DISTINCTCOUNT(Supported[Service Type])) )
如果我根據 SERIALNUMBER 繪制這個度量值,我會得到這個 output:
這讓我覺得我走在了正確的軌道上,因為它表明 6 個人得到了 3 項服務的支持——正如上面的示例 output 所證實的那樣。 但我希望這個數字 6 成為我的衡量標准。
我的報告中的所有 rest 都有效,但我不知道如何做最后一部分。 非常感謝您提供的任何建議。
首先,您需要為 Number of Services 創建一個維度表。
您可以使用 Power Query 執行此操作:
let Source = Table.FromList({1..List.Count(List.Distinct(Supported[Service Type]))},Splitter.SplitByNothing(),{"Number of Services"}), #"Changed Type" = Table.TransformColumnTypes(Source,{{"Number of Services", Int64.Type}}) in #"Changed Type"
或使用 DAX:
Services = GENERATESERIES ( 1, DISTINCTCOUNT ( Supported[Service Type] ) )
然后根據需要重命名列。
現在您可以創建幾個度量:
使用的服務數量:
Number of Services Used = DISTINCTCOUNT ( Supported[Service Type] )
人們:
People = COUNTROWS ( FILTER ( SUMMARIZE ( Supported, Supported[SERIALNUMBER], "NumServices", [Number of Services Used] ), [NumServices] >= MIN ( Services[Number of Services] ) && [NumServices] <= MAX ( Services[Number of Services] ) ) )
人數(累計):
People (Cumulative) = COUNTROWS ( FILTER ( SUMMARIZE ( Supported, Supported[SERIALNUMBER], "NumServices", [Number of Services Used] ), [NumServices] >= MIN ( Services[Number of Services] ) ) )
這為您的(微小)數據樣本提供了以下信息:
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.