cancel
Showing results for
Did you mean:  Helper III

## DECREASE THE VALUE AND ADD THE VALUE ACCORDING TO CATEGORY

Hi!

I have the following situation: I have 3 categories (A, B ,C) , their value and loss. I have to DEDUCT the loss from category A AND ADD IT TO category C.

EXAMPLE:

 CATEGORY VALUE LOSS A 100 20 B 120 0 C 50 0 TOTAL 270 20

EXPECTED RESULT:

 CATEGORY VALUE LOSS A 80 0 B 120 0 C 70 20 TOTAL 270 20

WHAT MEASURE COULD I BUILD?

THANKS! ~~

1 ACCEPTED SOLUTION  Super User I
try this.

result_test =
var VALA = CALCULATE(sum(Test[LOSS]), FILTER(ALLSELECTED(Test),Test[CATEGORY] ="A"))
return
IF(SELECTEDVALUE(Test[CATEGORY]) = "A", SUM(Test[VALUE]) - SUM(Test[LOSS]),
if(SELECTEDVALUE(Test[CATEGORY]) = "C", sum(Test[VALUE]) + VALA,
sum(Test[VALUE])))

Proud to be a Super User!

10 REPLIES 10  Super User I
try this.

result_test =
var VALA = CALCULATE(sum(Test[LOSS]), FILTER(ALLSELECTED(Test),Test[CATEGORY] ="A"))
return
IF(SELECTEDVALUE(Test[CATEGORY]) = "A", SUM(Test[VALUE]) - SUM(Test[LOSS]),
if(SELECTEDVALUE(Test[CATEGORY]) = "C", sum(Test[VALUE]) + VALA,
sum(Test[VALUE])))

Proud to be a Super User!  Helper III

Thank you for help! 🙂  Super User I
LossC=
var lossA = CALCULATE(sum('Table'[LOSS]), 'Table'[CATEGORY] = "A")
var valC = CALCULATE(sum('Table'[VALUE]), 'Table'[CATEGORY] = "C")
return valC + lossA

lossA=
var lossA = CALCULATE(sum('Table'[LOSS]), 'Table'[CATEGORY] = "A")
var valA = CALCULATE(sum('Table'[VALUE]), 'Table'[CATEGORY] = "A")
return valA - lossA

Proud to be a Super User!  Super User II

@ANM_97 , Need to create measures like this:

NEW VALUE  = SUM(Table[Value])-SUM(Table[Loss])

NEW LOSS = 0

OR NEW LOSS MEASURE = SUM(Table[Loss])-SUM(Table[Loss])

Don't forget to give thumbs up and accept this as a solution if it helped you!!!

Please take a quick glance at newly created dashboards : Restaurant Management Dashboard , HR Analytics Report , Hotel Management Report, and Sales Analysis Report  Helper III

It's not that simple. The value of LOSS = 20 must be subtracted from A and added to category C. I have attached a measure, but it does not add to category C.   Super User I

depends on how you want to use it

result  = sum('Table'[VALUE]) - sum('Table'[LOSS])

RESULT 2 = SUMX ( table, 'table'[value] - 'table'[loss] )

Proud to be a Super User!  Helper III

It's not that simple. The value of LOSS = 20 must be subtracted from A and added to category C. I have attached a measure, but it does not add to category C.   Helper III

I try this: But don't work ok, because the LOSS value is also low from the total value.  Super User I

I am not sure why you are asking for someone else to come and help when I am putting my time into helping you?    Please provide the code  you have used in text form so i can see what is going on

Proud to be a Super User!  Helper III
I appreciate the time you give. With the solution sent by you, I did not get the expected result. It would help me if you tested the measure before answering. I tried many options. This is the measure from the picture:

result_test =
VAR lossA = CALCULATE( sum(test[LOSS]), test[CATEGORY] = "A")
VAR valC = CALCULATE( sum(test[VALUE]), test[CATEGORY] = "B")
return
IF(FIRSTNONBLANK(test[CATEGORY],"") ="A", CALCULATE(SUM(test[VALUE]) - lossA),
IF(FIRSTNONBLANK(test[CATEGORY], "") ="C", CALCULATE(valC + lossA), SUM(test[VALUE]))) Announcements #### 2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022. #### Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps Top Solution Authors
Top Kudoed Authors
Users online (3,430)