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

To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.

Reply
hidenseek9
Post Patron
Post Patron

SUMX calculation is not working for only one scenario

Hi 

 

I am using the same calculation but this one calculation is not working. 

Can anyone figure out why that is?

 

I have a table with different volume scenarios as below. 

I am using NSKG(price) x volume to calculate sales such as below. 

All the calculation is identical, but for linear NS it is not working. 

calculation.png

Sales NS Calculation.png

Demand NS Calculation.png

Linear NS Calculation.png

 

Appreciate the support!

1 ACCEPTED SOLUTION
Shravan133
Super User
Super User

 

Ensure that the table passed to SUMX accurately represents the data you intend to iterate over. Using functions like VALUES() or SUMMARIZE() can help define the correct context.​

 

For example: 
TotalValue = SUMX( VALUES('YourTable'[YourColumn]), [MeasureA] * [MeasureB] / 1000 )

View solution in original post

6 REPLIES 6
v-pnaroju-msft
Community Support
Community Support

Thankyou, @Shravan133@danextian, for your response.

Hi @hidenseek9,

We appreciate your query on the Microsoft Fabric Community Forum.

Based on my understanding, since the measure Linear NS is not functioning while the measures Demand NS and Sales NS are operational, the issue may likely stem from the behavior of [Linear Vol] in the current model.

I would suggest the following approach to ensure proper row context, assuming [Linear Vol] is a measure. Please check if this resolves the issue:

Linear NS =

SUMX (

    ADDCOLUMNS (

        NSKG,

        "LinearVol", [Linear Vol]

    ),

    [LinearVol] * [RF NSKG] / 1000

)
 

This approach allows SUMX to evaluate [Linear Vol] correctly on a row-by-row basis. Additionally, please ensure that [Linear Vol] exists and is populated in the NSKG table and that there are no BLANK values or errors present in the data.

If you find our response helpful, kindly mark it as the accepted solution and provide feedback in the form of kudos. This will assist other community members who might be facing similar queries.

Thank you.

danextian
Super User
Super User

Hi @hidenseek9 

Your SUMX measure iterates over each row in the NSKG report, so the multiplication and division operations are performed row by row, rather than on the distinct values of the columns referenced in the black box. Use a table expression instead of a whole table.

Demand NS =
SUMX (
    ADDCOLUMNS (
        SUMMARIZE ( NSKG, NSKG[column1], NSKG[column2] ),  -- <-- Use your actual grouping columns
        "Vol", [Demand Vol],
        "RF", [RF NSKG]
    ),
    [Vol] * [RF] / 1000
)


Demand NS =
SUMX (
    VALUES(NSKG[column1]),
    [Demand Vol] * [RF NSKG] / 1000
)





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

Did I answer your question? Mark my post as a solution!


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

@danextian Thank you for the reply. This is highly complex.

Your solution worked at individual row but not for total as per below. 

Any reason why this may be?

TTL not correct.png

Shravan133
Super User
Super User

 

Ensure that the table passed to SUMX accurately represents the data you intend to iterate over. Using functions like VALUES() or SUMMARIZE() can help define the correct context.​

 

For example: 
TotalValue = SUMX( VALUES('YourTable'[YourColumn]), [MeasureA] * [MeasureB] / 1000 )

@Shhshsh Thank you for the solution. This worked perfectly!

Can you tell me what VALUES does specifically in this case?

I assume VALUES returns a distinct table, but without it what is SUMX referring to?

Hi,

The VALUES() function returns a table with unique entries.  Think of this as the UNIQUE() function of MS Excel.  The SUMX() function iterates over every row of this table and adds the measure value of each row.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

Top Solution Authors
Top Kudoed Authors