You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Power BI层级父级度量值实现:基于Area/Region层级筛选后展示区域及所属Area销售额卡片

Solution to Display Region and Parent Area Sales in Power BI Cards with Filters

Hey there! Let's walk through how to replicate your table's functionality using Power BI cards and filters—you're already halfway there with your existing DAX measure, so this should be straightforward.

Breakdown of Your Existing DAX

First, let's confirm we understand what your Above hierarchy measure does, since it's the core of this solution:

Above hierarchy = 
SWITCH(
    True,
    ISFILTERED('BD'[Region]), CALCULATE(FACT[Sales], ALL('BD'[Region])),
    ISFILTERED('BD'[Area]), CALCULATE(FACT[Sales], ALL('BD'[Area])),
    FACT[Sales]
)

This measure smartly adjusts based on your filter context:

  • When a Region is selected, it removes the Region filter to return the total sales for the parent Area
  • When an Area is selected, it removes the Area filter to return the total for the level above (if Area is your top hierarchy, this will be the overall total)
  • If no filters are active, it just returns raw sales values

Step-by-Step Setup for Cards & Filters

1. Create a Measure for Selected Region Sales

First, make a simple measure to isolate the sales of the specific Region users select:

Selected Region Sales = 
IF(
    ISFILTERED('BD'[Region]),
    SUM(FACT[Sales]),
    BLANK() // You can replace BLANK() with a default message like "Select a Region" if preferred
)

This will only show a value when a Region is picked in your filter.

2. Reuse Your Above hierarchy Measure for Parent Area Sales

Your existing measure already does exactly what we need for the parent Area's sales when a Region is filtered. No changes needed here—just plug it into the second card.

3. Configure the Filter and Cards

  • Add a slicer or filter pane for BD[Region] so users can select their desired Region.
  • Add your first Card visual, assign the Selected Region Sales measure to it, and set a clear label like "Selected Region Sales".
  • Add your second Card visual, assign the Above hierarchy measure to it, and label it "Parent Area Sales".

Example Behavior

When you select C100 in the Region filter:

  • The first card will display 1.9% (the sales for Region C100)
  • The second card will display 22.8% (the total sales for C100's parent Area, thanks to the ALL('BD'[Region]) logic in your measure)

Optional: Add Parent Area Label for Clarity

If you want users to see exactly which Area the second card refers to, create this quick measure and add it as a secondary label in the parent Area card:

Parent Area Name = 
IF(
    ISFILTERED('BD'[Region]),
    CALCULATE(VALUES('BD'[Area]), ALL('BD'[Region])),
    BLANK()
)

内容的提问来源于stack exchange,提问作者Lluis C

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.28 23:48:10