Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
Hi I am trying to do a subtraction unless a column has a specific value in it.
What Im trying to do is if the value of list = a then return valuea = 2 else do a subtraction valuea - valueb
I cant help but feel its simple but I can't see the solution.
List | valuea | valueb | Returned result |
a | 2 | 23 | 2 |
b | 3 | 2 | 1 |
c | 4 | 3 | 1 |
d | 5 | 4 | 1 |
e | 6 | 5 | 1 |
f | 7 | 6 | 1 |
Thanks in advance.
I had figured it out as I retired for the night.
This is what I did
Measure =
var tab =ADDCOLUMNS('Mytable',"Result",
if('Mytable'[List] = "a",calculate(sum(Mytable[valuea]) ,'Mytable'[List] = "a")
, [Dev minus For]))
return
sumx(tab,[Result])
Note [Dev minus For] is a measure that simply does valuea - valueb on all rows that I had origanaly created and reused.
Thanks for your replys and help.
Hello @David01
You can try this calculated column.
Hi @David01
Create a calculated column:
NewCol =
IF ( Table1[List] = "a", Table1[valuea], Table1[valuea] - Table1[valueb] )
|
Please accept the solution when done and consider giving a thumbs up if posts are helpful. Contact me privately for support with any larger-scale BI needs, tutoring, etc. |
User | Count |
---|---|
25 | |
11 | |
8 | |
6 | |
6 |
User | Count |
---|---|
27 | |
13 | |
11 | |
9 | |
6 |