如何在Power BI中将切片器值设置为第一个可用值形式表?

编程入门 行业动态 更新时间:2024-10-25 00:26:08
本文介绍了如何在Power BI中将切片器值设置为第一个可用值形式表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我要求切片器中选择的值必须有效.

让我们假设,如果我在商店切片器"中选择一个值,并且该商店被从公司中删除.切片器仍会显示其名称,而与切片器交互的视觉效果中没有数据.

已选择默认值

手动更新切片器值

但是我只希望在我的商店切片器中选择相关的商店.我知道它的切片器的属性可以保留在发布报表时在其中设置的值,但是有任何解决方法.

解决方案

您的问题的实质已在以下线程中被询问并覆盖:

这是一个可供下载的示例文件(M和DAX中都有这两种方法):

M默认切片器值.pbix

您可以通过添加计算表来完全在DAX中创建DimStore表:

DimStore_DAX =SUMMARIZECOLUMNS(销售[商店],销售",[销售],排名",RANKX(全部(销售[商店],[销售]),"StoreName",如果IF(RANKX(ALL(Sales [Store]),[Sale])= 1,最大的商店",VALUES(Sales [Store])))

I have a requirement that the selected value in slicer must be valid.

Let us suppose if I select a value in Store slicer and that store gets deleted from the company. The slicer will still show its name with no data in visuals interacting with the slicer.

Default Value Selected

Updated Slicer Value Manually

But I want only the relevant store selected in my Store slicer. I know its slicer's property to retain the value which is set in it while publishing the report, but is there any workaround for it.

解决方案

The essence of your question has been asked and covered in this thread:

Initial value of Power BI slicer based on another slicer choice

The answer is NO, but I can propose a workaround.

  • In the dimension table with stores, add a calculated column Rank which will determine the store with the highest sales. You may use RANKX function for that.
  • Add StoreName calculated column which returns the text value "The biggest store" (or "Top 1" - or whatever) and original store names for all the other stores. Use IF.
  • Put the column StoreName which contains "The biggest store" value to the slicer.
  • Add a visual (card, table) where you will display the original name of currently selected store.
  • Sort the column StoreName by Rank column designed for that purpose so that The biggest store will float up to the top position in the slicer. Here is how to sort the column by another column.
  • Since there is always a store with the highest sales you may always have that value ticked in the slicer and it will always show data.

    In this example "The biggest store" is "Store for girls". I keep it selected on the slicer. Then I remove all the records of that store from fact table. Apply. And the slicer is still selected as "The biggest store" but now the biggest store means "Store for ladybirds".

    Here is a sample file for download (with both approaches in M and DAX):

    M Default Slicer Value.pbix

    You can make DimStore table completely in DAX by adding calculated table:

    DimStore_DAX = SUMMARIZECOLUMNS ( Sales[Store], "Sales", [Sale], "Rank", RANKX ( ALL ( Sales[Store] ), [Sale] ), "StoreName", IF ( RANKX ( ALL ( Sales[Store] ), [Sale] ) = 1, "The biggest store", VALUES ( Sales[Store] ) ) )

    更多推荐

    如何在Power BI中将切片器值设置为第一个可用值形式表?

    本文发布于:2023-10-30 22:30:55,感谢您对本站的认可!
    本文链接:https://www.elefans.com/category/jswz/34/1544196.html
    版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
    本文标签:第一个   切片   设置为   中将   形式

    发布评论

    评论列表 (有 0 条评论)
    草根站长

    >www.elefans.com

    编程频道|电子爱好者 - 技术资讯及电子产品介绍!