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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
David01
Frequent Visitor

Calculate a value unless a column has a specific value.

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.

 

ListvalueavaluebReturned result
a2232
b321
c431
d541
e651
f761

 

Thanks in advance.

3 REPLIES 3
David01
Frequent Visitor

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.

Anonymous
Not applicable

Hello @David01 
You can try this calculated column.

Result =
IF(
Table[List] = "a",
Table[valuea],
Table[valuea] - Table[valueb]
)
AlB
Community Champion
Community Champion

Hi @David01 

Create a calculated column:

NewCol =
IF ( Table1[List] = "a", Table1[valuea], Table1[valuea] - Table1[valueb] )

 

SU18_powerbi_badge

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.

 

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.