Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
ClearRide
Frequent Visitor

Sum values of a measure in a hierarchy

ClearRide_0-1673282653400.png

Here is a segment of my data in a matrix with a hierarchy. Using 2 tables: Sales and Organization.
I want to sum the values of the measure [NF CountPlp Over Quota]. For example, Kelly Henrich should be 6 (not 1). Code for measure: 

IF([NF Over Quota] >=0 , 1, 0)

For the sake of the question, I will also leave what I have for the related measures since they might be apart of the solution: 
[NF Over Quota] = [Total NF] - [NF Over Quota]
[NF Quota] = SUM(Organization[NFQuota])
[Total NF] = CALCULATE(SUM('Sales'[NF Sold]), FILTER(Sales, Sales[Category] = 7))
 
I tried creating a calculated column with the same code IF([NF Over Quota] >=0 , 1, 0) and summing that, but it didn't work (got all 1s for some reason). I couldn't do SUM ([NF Over Quota]) because it's not a column.
Please let me know if you need more information, thank you.
Edit: Here is the pbix https://drive.google.com/file/d/1IHv7iVGpX7wUzrGO8rcu63_KJBhZ9erc/view?usp=share_link
1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi  @ClearRide ,

 

Here are the steps you can follow:

1. Create measure.

Measure =
var _table1=SUMMARIZE('Sales','Sales'[DSR],"Value",[NF CountPlp Over Quota])
return
IF(
    ISINSCOPE('Sales'[DSR]),[NF CountPlp Over Quota],SUMX(_table1,[Value])

2. Result:

vyangliumsft_0-1673315510535.png

 

Best Regards,

Liu Yang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

View solution in original post

5 REPLIES 5
Anonymous
Not applicable

Hi  @ClearRide ,

 

Here are the steps you can follow:

1. Create measure.

Measure =
var _table1=SUMMARIZE('Sales','Sales'[DSR],"Value",[NF CountPlp Over Quota])
return
IF(
    ISINSCOPE('Sales'[DSR]),[NF CountPlp Over Quota],SUMX(_table1,[Value])

2. Result:

vyangliumsft_0-1673315510535.png

 

Best Regards,

Liu Yang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

sevenhills
Super User
Super User

You need to use in your calculation HASONEFILTER and ISINSCOPE.

We dont have your data model sample, so please refer to this article as it explains clearly.

 

https://www.kasperonbi.com/use-isinscope-to-get-the-right-hierarchy-level-in-dax/

 

Thank you for letting me know, I have provide the pbix for a closer look.

 

Use this one and see if it works.

NF CountPlp Over Quota = 
SWITCH (
  TRUE (),
  ISINSCOPE(Sales[DSR]), IF([NF Over Quota] >=0 , 1, 0),  -- you can use HASONEFILTER, ISFiltered also
    SUMX( 
         SUMMARIZE(Sales, Sales[DSR] -- field used in the matrix
                , "To Sum Over Quota", IF([NF Over Quota] >=0 , 1, 0))
         , [To Sum Over Quota])
)

 

 

sevenhills_0-1673384598586.png

 

I renamed your old measure as "NF CountPlp Over Quota Issue"

 

 

Same can be achieved similarly as below:

NF Count Plp Over Quota 2 = 

var _t = FILTER( 
            SUMMARIZE( 'Sales', Sales[Division], Sales[DSM], Sales[DSR], 
                  "NF Quota", [NF Quota], 
                  "Total NF", [Total NF]) 
            , [Total NF] - [NF Quota] >= 0
            )

return  IF (HASONEFILTER(Sales[DSR]), 
              IF([Total NF] - [NF Quota] >=0 , 1, 0), 
              COUNTROWS(_t) 
        )

-- Below line also works
-- return  IF (HASONEFILTER(Sales[DSR]), IF([Total NF] - [NF Quota] >=0 , 1, 0), sumx(_t, IF([Total NF] - [NF Quota] >=0 , 1, 0)) )

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors