最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

powerbi - Power BI - how to all ALL(Table) to a measure - remove all filters - Stack Overflow

programmeradmin3浏览0评论

How can I add ALL(UPS) to the following measure, so the card value will remain the same:

Measure = VAR Total_Sum = (SUM('UPS'[1st_UPS]) + SUM('UPS'[2nd_UPS])) VAR Non_Zero_Count = SUMX('UPS',IF('UPS'[1st_UPS] = 0, 0, 1) + IF('UPS'[2nd_UPS] =0, 0, 1)) RETURN if(Non_Zero_Count=0,0,Total_Sum/Non_Zero_Count)

How can I add ALL(UPS) to the following measure, so the card value will remain the same:

Measure = VAR Total_Sum = (SUM('UPS'[1st_UPS]) + SUM('UPS'[2nd_UPS])) VAR Non_Zero_Count = SUMX('UPS',IF('UPS'[1st_UPS] = 0, 0, 1) + IF('UPS'[2nd_UPS] =0, 0, 1)) RETURN if(Non_Zero_Count=0,0,Total_Sum/Non_Zero_Count)

Share asked Mar 31 at 2:22 cghantacghanta 373 bronze badges New contributor cghanta is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
Add a comment  | 

1 Answer 1

Reset to default 1

You need to use CALCULATE to be able to use ALL :

Measure = 
VAR UPS_Table = 
    CALCULATETABLE('UPS', ALL('UPS'))

VAR Total_Sum = 
    SUMX(UPS_Table, 'UPS'[1st_UPS] + 'UPS'[2nd_UPS])

VAR Non_Zero_Count = 
    SUMX(
        UPS_Table,
        IF('UPS'[1st_UPS] <> 0, 1, 0) + IF('UPS'[2nd_UPS] <> 0, 1, 0)
    )

RETURN
    DIVIDE(Total_Sum, Non_Zero_Count, 0)

发布评论

评论列表(0)

  1. 暂无评论