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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
ikibirev
Frequent Visitor

Sum of values on separate rows for a complicated formula.

Hello!

 

I have a table like that (I've simplified a real case to make it easier to demonstrate.):

 

ikibirev_1-1639990937369.png

 

There are two columns with some numeric values (Value 1 and Value2) and two columns with weights (Weight1 and Weight2), which are calculated according to the following formulas:

Weight1 = divide('Table1'[Value1], calculate('Table1'[Value1], allselected('Table1')))

Weight2 = divide('Table1'[Value2], calculate('Table1'[Value2], allselected('Table1')))

 

Then I try to calculate the effect using some complicated formula. For example, like this:

Effect = (Weigth2 - Weight1) * Value2 / Value1

 

So I got perfect row result. But on total line I got 0,00. This is correct if we apply the formula, but I want to show the sum by rows.

Maybe in different measure... I need to calculate 0,11 - 0,10 + 0,11 = 0,12

How to calculate it?

 

1 ACCEPTED SOLUTION

Hi @ikibirev ,

Please try to update the formula of your measure [Effect] as below and check whether it can get the correct result. Please find the details in the attachment.

PS: The part with red font is new added one...

Effect =
VAR _tab =
ADDCOLUMNS (
ALLEXCEPT ( 'Table1', 'Table1'[Type] ),
"@effect",
( [Weight2] - [Weight1] ) * [Value2] / [Value1]
)
RETURN
SUMX ( _tab, [@effect] )

yingyinr_0-1641368542214.png

If the above one can't help you get the correct result, please provide some raw date(exclude sensitive data) and your expected result with calculation logic and special examples. It is better if you can share a simplified pbix file. Thank you.

Best Regards

Community Support Team _ Rena
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

4 REPLIES 4
amitchandak
Super User
Super User

@ikibirev , hope these are measures like

 

Weight1 = divide(sum('Table1'[Value1]), calculate(sum('Table1'[Value1]), allselected('Table1')))

Weight2 = divide(sum('Table1'[Value2], calculate(sum('Table1'[Value2]), allselected('Table1')))

 

Effect = divide((Weigth2 - Weight1) * sum(Table1[Value2]) , sum(Table1[Value1]))

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

Amitchandak, thank you very much for your answer!

 

But I got zero value in total line for this variant of formula too...

 

ikibirev_1-1639994215678.pngikibirev_2-1639994246135.png

 

ikibirev_3-1639994280925.png

 

How do I get the sum of the rows?

0,11 + (-0,10) + 0,11 = 0,12

 

 

Hi @ikibirev ,

Please try to update the formula of your measure [Effect] as below and check whether it can get the correct result. Please find the details in the attachment.

PS: The part with red font is new added one...

Effect =
VAR _tab =
ADDCOLUMNS (
ALLEXCEPT ( 'Table1', 'Table1'[Type] ),
"@effect",
( [Weight2] - [Weight1] ) * [Value2] / [Value1]
)
RETURN
SUMX ( _tab, [@effect] )

yingyinr_0-1641368542214.png

If the above one can't help you get the correct result, please provide some raw date(exclude sensitive data) and your expected result with calculation logic and special examples. It is better if you can share a simplified pbix file. Thank you.

Best Regards

Community Support Team _ Rena
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

You are a genius! You cannot imagine how grateful I'm to you! Many thanks!
It works! It remains to realize exactly how... 😉

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.