Power BI DAX - 具有过滤器的总列的百分比 [英] Power BI DAX - Percent of Total Column with FILTERs

查看:31
本文介绍了Power BI DAX - 具有过滤器的总列的百分比的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对 Power BI 比较陌生 - 在衡量指标中寻求占总数百分比"逻辑的帮助时,我一直在寻找高低的帮助,并且只找到了未应用过滤器且我需要在 DAX 代码中应用过滤器的示例.

I'm relatively new to Power BI - have looked high and low for help with "percent of total" logic in a measure and have found only examples where filters ARE NOT applied and I need to apply filters in the DAX code.

我想出了以下内容,这给了我所有的(100% 的值,而不是总数的百分比).我认为我需要对 ALLSELECTED 等做一些不同的事情,但可以使用你们任何人的任何想法.顺便说一句,我已经尝试过 SUM、SUMX、ALL、ALLEXCEPT、ALLSELECTED 等的所有组合.非常感谢您的指导.

I have come up with the following, which gives me all ones (100% values instead of the percentages of the total). I think I need to do something different with the ALLSELECTED, etc., but could use any thoughts that any of you have. BTW, I have tried every combination of SUM, SUMX, ALL, ALLEXCEPT, ALLSELECTED, etc. Many thanks in advance for your guidance.

Mix % =
CALCULATE (
    SUM ( service_line_analysis_unpivot[Value] ),
    service_line_analysis_unpivot[Attribute] = "netrevenue"
)
    / CALCULATE (
        SUMX ( service_line_analysis_unpivot, service_line_analysis_unpivot[Value] ),
        FILTER (
            service_line_analysis_unpivot,
            service_line_analysis_unpivot[Attribute] = "netrevenue"
        ),
        ALLSELECTED ()
    )

推荐答案

如果您希望净收入除以切片器/过滤器选择中所有内容的总净收入,那么我认为这就是您想要的:

If you want net revenue divided by total net revenue for everything in your slicer/filter selection, then I think this is what you want:

Mix % =
DIVIDE (
    CALCULATE (
        SUM ( service_line_analysis_unpivot[Value] ),
        service_line_analysis_unpivot[Attribute] = "netrevenue"
    ),
    CALCULATE (
        SUM ( service_line_analysis_unpivot[Value] ),
        service_line_analysis_unpivot[Attribute] = "netrevenue",
        ALLSELECTED ()
    )
)

如果这不正确,那么我们需要查看有关您的数据表、过滤器和视觉对象的更多详细信息.

If that's not right, then we'll need to see more detail on your data table, filters, and visuals.

这篇关于Power BI DAX - 具有过滤器的总列的百分比的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆