颜色三个最差的性能类别在条形图功能BI中

发布于 2025-01-20 03:42:56 字数 757 浏览 2 评论 0原文

我想在带有不同颜色的条形图中通过销售显示三个最差的表现子类别。这是我目前正在处理的dasboard,您可以在此处获取数据示例 sales sales超级明星数据集示例
有任何措施的想法吗?请提前

编辑:我以以下措施解决了:

Top N = 
IF
    (SELECTEDVALUE(
        superstore[Sub-Category])
        IN TOPN ( 
            3, 
            FILTER(
                ALLSELECTED(
                    superstore[Sub-Category]),
                    CALCULATE(
                        SUM(
                            superstore[Sales]))>0),
            CALCULATE(SUM(superstore[Sales])),
            ASC),
    "#FD625E",
    "#01B8AA"
)

I would like to display the three worst performing sub-categories by sales in a bar chart with a different color. This is the dasboard I'm currently working on, you can get a sample of the Data here Sales Superstore Dataset Sample.
Any ideas for a measure? Thanks in advance

edit: I solved it with following measure:

Top N = 
IF
    (SELECTEDVALUE(
        superstore[Sub-Category])
        IN TOPN ( 
            3, 
            FILTER(
                ALLSELECTED(
                    superstore[Sub-Category]),
                    CALCULATE(
                        SUM(
                            superstore[Sales]))>0),
            CALCULATE(SUM(superstore[Sales])),
            ASC),
    "#FD625E",
    "#01B8AA"
)

enter image description here

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

日暮斜阳 2025-01-27 03:42:56

进行一些调试,这是最终的结果,并且应该对您有用。过滤后条形图未着色的原因是,在度量内生成的表格将不相关子类别的空白值放入当前选定的过滤器中,而不是删除它们。下面的代码正是这样做的,它应该是这样的。检查一下并告诉我是否解决了您的问题。

Highlight Top N = 
VAR topX = 2
VAR value_to_highlight =
    MAXX(
        TOPN (
            topX,
            CALCULATETABLE (
                ADDCOLUMNS (
                    SUMMARIZE ( Data, Data[Category2] ),
                    "@totalValue", CALCULATE ( [Total Value] )
                ),
                ALL( Data[Category2] )
            ),
            [@totalValue], ASC
        ),
        [@totalValue]
    )
VAR result = 
    SWITCH(
        TRUE(),
        [Total Value] <= value_to_highlight, "red",
        "blue"
    )
RETURN 
    result

结果:
输入图片此处描述

A bit of debugging and here is the final result that work and should work for you either. The reason why the bars are not colored after filtering is that, the table that is generated inside your measure put blank values for non-related sub-categories to current selected filter instead of removing them. The code below is doing exactly that, what it should be. Check it out and let me know if it solved your problem.

Highlight Top N = 
VAR topX = 2
VAR value_to_highlight =
    MAXX(
        TOPN (
            topX,
            CALCULATETABLE (
                ADDCOLUMNS (
                    SUMMARIZE ( Data, Data[Category2] ),
                    "@totalValue", CALCULATE ( [Total Value] )
                ),
                ALL( Data[Category2] )
            ),
            [@totalValue], ASC
        ),
        [@totalValue]
    )
VAR result = 
    SWITCH(
        TRUE(),
        [Total Value] <= value_to_highlight, "red",
        "blue"
    )
RETURN 
    result

Result:
enter image description here

霓裳挽歌倾城醉 2025-01-27 03:42:56

您可以使用此视频中所示的DAX函数开关:

https 。

You can use the DAX function SWITCH as shown in this video:

https://www.youtube.com/watch?v=fOErC7eaWZ0&ab_channel=RADACAD

Let me know if it works for you

冷情妓 2025-01-27 03:42:56

我注意到,条件格式不适用于条形图。但是我们可以通过替代方式实现。

  1. 将销售领域纳入传奇&amp;条形图的值。
  2. 转到可视化窗格&amp;打开Visual&gt;列列
  3. 列列表按销售价值的上升顺序。
  4. 前三种颜色是最糟糕的销售,因此颜色&amp;在其余列中应用任何一种颜色。
  5. 您所需的条形图已准备就绪。

希望它能解决您的查询。请参阅屏幕截图

I noticed, Conditional formatting not available for bar charts. But we can achieve by alternate way.

  1. Put Sales field into LEGENDS & VALUES of bar chart.
  2. Go to the visualizations pane & open Visual>>Columns
  3. Column colors list are in ascending order of sales value.
  4. First three colors are worst sale, color accordingly & apply any one color in rest of the columns.
  5. Your desired bar graph is ready.

Hope it will resolve your query.Please refer screenshot

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文