我要求切片器中的选定值必须有效。
让我们假设如果我在 Store slicer 中选择一个值,并且该商店从公司中删除。切片器仍将显示其名称,而与切片器交互的视觉对象中没有数据。
选择的默认值
手动更新切片器值
但我只想要在我的商店切片器中选择的相关商店。我知道它的切片器属性可以保留在发布报告时在其中设置的值,但是是否有任何解决方法。
我要求切片器中的选定值必须有效。
让我们假设如果我在 Store slicer 中选择一个值,并且该商店从公司中删除。切片器仍将显示其名称,而与切片器交互的视觉对象中没有数据。
选择的默认值
手动更新切片器值
但我只想要在我的商店切片器中选择的相关商店。我知道它的切片器属性可以保留在发布报告时在其中设置的值,但是是否有任何解决方法。
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.
Rank
which will determine the store with the highest sales. You may use RANKX function for that. 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.StoreName
which contains "The biggest store"
value to the slicer. 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):
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] )
)
)
发生这种情况只是因为它是您的默认值,否则一旦从您的基础中删除,切片器应该会自动丢失这些值。如果可能,更改您的默认值以反映商店价值,您确信它会一直存在。我相信即使没有数据也会保留默认值。另一种方法是默认所有商店,然后让用户选择所需的内容。这可能不是您想要的,因为我不知道您的具体要求,但希望它可以帮助您找到解决方案。