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! Learn more

Reply
salman_ali
Helper IV
Helper IV

Sumx multipling total with number of rows

Hello 

 

this is my measure 

 

salman_ali_0-1605031710698.png

here the measure calculate count of rows in orders pending table, where column will_call_tank = 'y'

this formula works when hasonevalue, however when I sumx for rollup value it multiplies the result by count of rows.

 

ths is the output I am getting

 

salman_ali_3-1605031894502.png

 

here DELcenter (Morden, Brandon, Winnpeg) are providing current values as 2, 6, and 9 respetively, however the rollup at the market level 100-Manitoba, ought to be 27, not 81.  The sumx is taking 27 and mulitplying by 3 (rows os del center) to give me 81.

 

why is this happening?

1 ACCEPTED SOLUTION
AlB
Community Champion
Community Champion

@salman_ali 

Try

Measure =
SUMX (
    VALUES ( F0006s[Description] ),
    CALCULATE ( COUNTROWS ( OrdersPending ), OrdersPending[will_call_tank] = "y" )
)

or

currentwcorders =
SUMX (
    VALUES ( OrdersPending[DelCenter] ),
    CALCULATE ( COUNTROWS ( OrdersPending ), OrdersPending[will_call_tank] = "y" )
)

Please mark the question solved when done and consider giving a thumbs up if posts are helpful.

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

Cheers 

SU18_powerbi_badge

View solution in original post

11 REPLIES 11
AlB
Community Champion
Community Champion

@salman_ali 

Where is the table you showed earlier in the report you've shared? I cannot find it 🤔

 

Please mark the question solved when done and consider giving a thumbs up if posts are helpful.

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

Cheers 

SU18_powerbi_badge

 

@AlB 

 

I have pasted snip of both the table and measure.  Do you see it in the file?

 

salman_ali_0-1605045061202.png

 

 

salman_ali_1-1605045128668.png

 

that table is in the shifting tab, top right 

 

it is the table on top of "COUnt of Pending orders by Forecast"

AlB
Community Champion
Community Champion

@salman_ali 

Ok, i found it. Unfortunately I cannot make changes to the report to try a couple of things because it has a live connection. and i don't have access to that connection. So I'm  abit blind here. Try:

Measure =
SUMX (
    VALUES ( F0006s[Description] ),
    CALCULATE (
        COUNTROWS ( OrdersPending ),
        FILTER ( OrdersPending, OrdersPending[will_call_tank] = "y" )
    )
)

Please mark the question solved when done and consider giving a thumbs up if posts are helpful.

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

Cheers 

 

SU18_powerbi_badge

 

 

@AlB  yeah thanks for trying, I tried the above measure, same result.  Not sure why this is happening, but I think your first explanation sounded correct 

AlB
Community Champion
Community Champion

@salman_ali 

Try

Measure =
SUMX (
    VALUES ( F0006s[Description] ),
    CALCULATE ( COUNTROWS ( OrdersPending ), OrdersPending[will_call_tank] = "y" )
)

or

currentwcorders =
SUMX (
    VALUES ( OrdersPending[DelCenter] ),
    CALCULATE ( COUNTROWS ( OrdersPending ), OrdersPending[will_call_tank] = "y" )
)

Please mark the question solved when done and consider giving a thumbs up if posts are helpful.

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

Cheers 

SU18_powerbi_badge

wow!! the first one worked!!!! thank you so much !!!

AlB
Community Champion
Community Champion

Hi @salman_ali 

Because you are assigning the result to a variable. At the subtotal row, when you create the variable there is no row context and the filter context is 100-Manitoba. For that, the number of rows with will_call_tank = 'y' is 2+6+19 = 27, which is stored in the variable. Then, you run the SUMX( ) over VALUES( .Del Center). There are 3 rows in that VALUES(). For each row,  you assign the value of the variable. So with the SUMX you have 3x that value, i.e., 3x27=81

There is row context within the SUMX but context transition is not being triggered. Plus remember that variables are immutable in DAX; their value will never change after creation. In that sense they act more as constants than as variables (as typically known in other programming languages)

You can simplify the measure:

Measure V2 = 
SUMX( VALUES( OrdersPending[DelCenter]), CALCULATE(...........) )

where the CALCULATE is what you are assigning to the VAR

Next time, please paste the code in text so that it can be copied and modified easily

 

Please mark the question solved when done and consider giving a thumbs up if posts are helpful.

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

Cheers 

SU18_powerbi_badge

   

Thanks @AlB  i tried using this measure

 

currentwcorders = SUMX(values(OrdersPending[DelCenter]), CALCULATE(COUNTROWS(OrdersPending),filter(OrdersPending,OrdersPending[will_call_tank]="y")))
 
but output is still the same 
AlB
Community Champion
Community Champion

@salman_ali 

If the results for the storage rows are correct, the result for the subtotal should be too. I'd need to see the pbix. Can you share it?

Please mark the question solved when done and consider giving a thumbs up if posts are helpful.

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

Cheers 

SU18_powerbi_badge

@AlB  i don't know how to send sample pbix, but i am sending you the wetransfer link 

 

pbix file  

 

hopefully this works.  this is the full pbix model.  let me know if it is too confusing

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