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

The FabCon + SQLCon recap series starts April 14th at 8am Pacific. If you’re tracking where AI is going inside Fabric, this first session is a can't miss. Register now

Reply
Shan_Drex12
Helper I
Helper I

If not custom column

Hi All,

 

I'm looking to calculating a custom column in power query using a if statement.

 

I have this column 1 ( scac) that IF it equals to the specific codes below it would mutiple Column 2 (# of days) by $250.

 

Column 1 (scac)Column 2 (# of days)
MONO

5

SHEK10
VTEC12

 

IF not then multiply column 2 (# of days) by $35.

 

I have this formula, below but it seems to not to be working, 

If [SCAC] = "MONU" or [SCAC] = "SHEK" or [SCAC] = "VTEC" then [# "of Days in Detention"] * 250 else [# "of Days in Detention"] * 35

1 ACCEPTED SOLUTION
Jimmy801
Community Champion
Community Champion

Hello @Shan_Drex12 

 

the formula has to be like this

if [#"Column 1 (scac)"]="MONO" or [#"Column 1 (scac)"]="SHEK" or [#"Column 1 (scac)"]="VTEC" then [#"Column 2 (# of days)"]*250 else [#"Column 2 (# of days)"]*35

here the complete example

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45W8vX381fSUTJVitWJVgr2cPUGcgwNwLywEFdnEM9IKTYWAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Column 1 (scac)" = _t, #"Column 2 (# of days)" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Column 1 (scac)", type text}, {"Column 2 (# of days)", Int64.Type}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each if [#"Column 1 (scac)"]="MONO" or [#"Column 1 (scac)"]="SHEK" or [#"Column 1 (scac)"]="VTEC" then [#"Column 2 (# of days)"]*250 else [#"Column 2 (# of days)"]*35)
in
    #"Added Custom"

 

Copy paste this code to the advanced editor in a new blank query to see how the solution works.

If this post helps or solves your problem, please mark it as solution (to help other users find useful content and to acknowledge the work of users that helped you)
Kudoes are nice too

Have fun

Jimmy

View solution in original post

1 REPLY 1
Jimmy801
Community Champion
Community Champion

Hello @Shan_Drex12 

 

the formula has to be like this

if [#"Column 1 (scac)"]="MONO" or [#"Column 1 (scac)"]="SHEK" or [#"Column 1 (scac)"]="VTEC" then [#"Column 2 (# of days)"]*250 else [#"Column 2 (# of days)"]*35

here the complete example

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45W8vX381fSUTJVitWJVgr2cPUGcgwNwLywEFdnEM9IKTYWAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Column 1 (scac)" = _t, #"Column 2 (# of days)" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Column 1 (scac)", type text}, {"Column 2 (# of days)", Int64.Type}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each if [#"Column 1 (scac)"]="MONO" or [#"Column 1 (scac)"]="SHEK" or [#"Column 1 (scac)"]="VTEC" then [#"Column 2 (# of days)"]*250 else [#"Column 2 (# of days)"]*35)
in
    #"Added Custom"

 

Copy paste this code to the advanced editor in a new blank query to see how the solution works.

If this post helps or solves your problem, please mark it as solution (to help other users find useful content and to acknowledge the work of users that helped you)
Kudoes are nice too

Have fun

Jimmy

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.