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

Get certified in Microsoft Fabric—for free! For a limited time, the Microsoft Fabric Community team will be offering free DP-600 exam vouchers. Prepare now

Reply
chenko90
Frequent Visitor

Summing on multiple rows

Hi,

I am trying to create a measure that will sum my values based on two rows. My current formula is: 

SUMX(VALUES(Table[customer]),Table[Price Variance]) 

What i actually need is for the measure to sum the price variance based on the product within each customer. If I put produt in the SUMX formula then it disregards the customer and if i put customer then it doesn't take into account the product. Is there a way to tell it to consider both? 

 

Below is kind of what i am getting. The product numbers are right but then it summarizes it on customer so that one is wrong. I need it to say $20. 

Customer Name     $30

       Product A         $10

       Product B         $10

 

Hope this makes sense.

1 ACCEPTED SOLUTION

@chenko90 , This only need when Price Variance is measure

 

SUMX(summarize(Table, Table[Product], Table[customer]), "_1", Table[Price Variance]), [_1]) 

 

 

when price variance is a column

SUMX(summarize(Table, Table[Product], Table[customer], Table[Price Variance]), [Price Variance])

 

If this does not help
Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

View solution in original post

5 REPLIES 5
v-yangliu-msft
Community Support
Community Support

Hi  @chenko90 ,

I created some data:

vyangliumsft_0-1646021128126.png

Here are the steps you can follow:

Method one

Create measure.

method one =
var _1=SUMMARIZE('Table','Table'[MAJOR_NAME],'Table'[SKU],'Table'[Price Vanriance])
return
SUMX(_1,[Price Vanriance])

Result:

vyangliumsft_1-1646021128128.png

Second method

Create measure.

second method_1 =
IF(ISINSCOPE('Table'[MAJOR_NAME])&& NOT(ISINSCOPE('Table'[SKU])),SUMX('Table',[Price Vanriance]),MAX('Table'[Price Vanriance]))
second method_2 =
var _table=SUMMARIZE('Table','Table'[MAJOR_NAME],"_value",[second method_1])
return
IF(HASONEVALUE('Table'[MAJOR_NAME]),[second method_1],SUMX( _table,[_value]))

Result:

vyangliumsft_2-1646021128129.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

ValtteriN
Super User
Super User

Hi,

Typically a simple SUM should work in these kinds of cases, but I assume there is some issue with using it. Try adding DISTINCT before your VALUES so something like this: 

DISTINCT(VALUES(Table[customer]). It is somewhat difficult to understand what is going on here. Do you have some sort of sample data?

I hope this post helps to solve your issue and if it does consider accepting it as a solution and giving the post a thumbs up!

My LinkedIn: https://www.linkedin.com/in/n%C3%A4ttiahov-00001/




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

Proud to be a Super User!




Here is a visual of what im working with. As you can see the total for customer A is wrong. The sku level numbers are correct. When i use the SUM formula it has the same issue where it runs the formula in the measure instead of summing the sku level numbers. 

chenko90_0-1645656716488.png

 

@chenko90 , This only need when Price Variance is measure

 

SUMX(summarize(Table, Table[Product], Table[customer]), "_1", Table[Price Variance]), [_1]) 

 

 

when price variance is a column

SUMX(summarize(Table, Table[Product], Table[customer], Table[Price Variance]), [Price Variance])

 

If this does not help
Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

What does the "_1" mean?

Helpful resources

Announcements
OCT PBI Update Carousel

Power BI Monthly Update - October 2024

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

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

October NL Carousel

Fabric Community Update - October 2024

Find out what's new and trending in the Fabric Community.

Top Kudoed Authors