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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
Anonymous
Not applicable

Subtraction only if result is not X

Hi all,

 

I had a question I want to subtract a fixed value from a column BUT only when the result is => 5, so for example:

If my fixed value is 5 I want the result to look like this: (I want this result as a calculated column)

2015
3025
2520
00
5045
55

 

Thanks in advance !

 

Best Regards,

L.Meijdam

1 ACCEPTED SOLUTION
jthomson
Solution Sage
Solution Sage

newcolumnname=if([existingcolumnname]<5,[existingcolumnname],[existingcolumnname]-5) should work

View solution in original post

7 REPLIES 7
WolfBiber
Microsoft Employee
Microsoft Employee

Try following code, you need to change Source here of course, FixedParam is a Parameter of type Number

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjJQ0lEyNFWK1YlWMgaxjSBsIKUDkgSxQcIQlimIaQJRAVIAZMUCAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Column1 = _t, Column2 = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Column1", Int64.Type}, {"Column2", Int64.Type}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each if [Column1] > FixedParam then [Column1]-5 else [Column1])
in
    #"Added Custom"

 

jthomson
Solution Sage
Solution Sage

newcolumnname=if([existingcolumnname]<5,[existingcolumnname],[existingcolumnname]-5) should work

Anonymous
Not applicable

Hi @jthomson,

 

I get the error message stating "The end of input was reached."

 

Hi@WolfBiber,

 

If possible I am looking for a solution in DAX

 

Best regards,

L.Meijdam

 

then use formula from @jthomson and replace , with ; 

newcolumnname=if([existingcolumnname]<5;[existingcolumnname];[existingcolumnname]-5)
Anonymous
Not applicable

Hi @WolfBiber,

 

I already do that by default so it is not making a difference.

 

Best regards,

L.Meijdam

@Anonymous

 

The formula provided by @WolfBiber and @jthomson should work. You need to add this calculated column outside of Query Editor. 

 

24.PNG

 

Regards,

Anonymous
Not applicable

Hi @v-sihou-msft@WolfBiber@jthomson

 

I am not sure what I did but the code is returning no errors anymore .. I made no changes.

 

But anyway thanks for the help the code provided works like expected now !

 

Best Regards,

L.Meijdam

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors