cancel
Showing results for
Did you mean:
Helper IV

## 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
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])))

If I took the time to answer your question and I came up with a solution, please mark my post as a solution and /or give kudos freely for the effort 🙂 Thank you!

Proud to be a Super User!

10 REPLIES 10
Super User
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])))

If I took the time to answer your question and I came up with a solution, please mark my post as a solution and /or give kudos freely for the effort 🙂 Thank you!

Proud to be a Super User!

Helper IV

Thank you for help! 🙂

Super User
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

If I took the time to answer your question and I came up with a solution, please mark my post as a solution and /or give kudos freely for the effort 🙂 Thank you!

Proud to be a Super User!

Super User

@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, Sales Analysis Report , and Fortune 500 Companies Analysis
Helper IV

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

depends on how you want to use it

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

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

If I took the time to answer your question and I came up with a solution, please mark my post as a solution and /or give kudos freely for the effort 🙂 Thank you!

Proud to be a Super User!

Helper IV

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 IV

I try this:

But don't work ok, because the LOSS value is also low from the total value.

Super User

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

If I took the time to answer your question and I came up with a solution, please mark my post as a solution and /or give kudos freely for the effort 🙂 Thank you!

Proud to be a Super User!

Helper IV
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