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

A new Data Days event is coming soon! This time we’re going bigger than ever. Fabric, Power BI, SQL, AI and more. Don't miss out.

Reply
mvazquez21
Regular Visitor

Power Query If statement

Is there a way to simplify the following if statement?  Power Query takes long to process because I have this if statement for each month.  Depending on the condition, it multiplies the value by either [#"ref_HC_Data_Actuals.% of Total"], [#"ref_HC_Data_Actuals.% of Total 2"], [#"ref_HC_Data_Actuals.% of Total 3"], or [#"ref_HC_Data_Actuals.% of Total 4"].

 

 

= Table.AddColumn(#"Added FY19 Dec Final", "FY20 Jan Final", each if Text.StartsWith([Cost Center], "411") then [#"FY20 - Jan"] * [#"ref_HC_Data_Actuals.% of Total 4"]

else if Text.StartsWith([Cost Center], "412") then [#"FY20 - Jan"] * [#"ref_HC_Data_Actuals.% of Total 4"]

else if Text.StartsWith([Cost Center], "4") and Text.Contains([Vendor Name],"Winston & Strawn") then [#"FY20 - Jan"] * [#"ref_HC_Data_Actuals.% of Total"]

else if Text.StartsWith([Cost Center], "4") and Text.Contains([Vendor Name],"Kramer Levin") then [#"FY20 - Jan"] * [#"ref_HC_Data_Actuals.% of Total"]

else if Text.StartsWith([Cost Center], "4") and Text.Contains([Vendor Name],"Prudential") then [#"FY20 - Jan"] * [#"ref_HC_Data_Actuals.% of Total"]

else if Text.StartsWith([Cost Center], "4") and Text.Contains([Vendor Name],"Charles Schwab") then [#"FY20 - Jan"] * [#"ref_HC_Data_Actuals.% of Total"]

else if Text.StartsWith([Cost Center], "4") and Text.Contains([Vendor Name],"Wise Consulting") then [#"FY20 - Jan"] * [#"ref_HC_Data_Actuals.% of Total"]

else if Text.StartsWith([Cost Center], "4") and Text.Contains([Vendor Name],"Tata Consultancy") then [#"FY20 - Jan"] * [#"ref_HC_Data_Actuals.% of Total"]

else if Text.StartsWith([Cost Center], "4") and Text.Contains([Vendor Name],"Microsoft") then [#"FY20 - Jan"] * [#"ref_HC_Data_Actuals.% of Total"]

else if Text.StartsWith([Cost Center], "4") and Text.Contains([Vendor Name],"Interstate Business Park") then [#"FY20 - Jan"] * [#"ref_HC_Data_Actuals.% of Total 2"]

else if Text.StartsWith([Cost Center], "4") and Text.Contains([Vendor Name],"Legacy Parking") then [#"FY20 - Jan"] * [#"ref_HC_Data_Actuals.% of Total 2"]

else if Text.StartsWith([Cost Center], "4") and Text.Contains([Vendor Name],"Metro Parking") then [#"FY20 - Jan"] * [#"ref_HC_Data_Actuals.% of Total 2"]

else if Text.StartsWith([Cost Center], "4") and Text.Contains([Vendor Name],"Ponte Gadea Biscayne") then [#"FY20 - Jan"] * [#"ref_HC_Data_Actuals.% of Total 2"]

else if Text.StartsWith([Cost Center], "4") and Text.Contains([Vendor Name],"SCRS 2800 Ponce de Leon") then [#"FY20 - Jan"] * [#"ref_HC_Data_Actuals.% of Total 2"]

else if Text.StartsWith([Cost Center], "4") and Text.Contains([Vendor Name],"600 Partners") then [#"FY20 - Jan"] * [#"ref_HC_Data_Actuals.% of Total 3"]

else if Text.StartsWith([Cost Center], "4") and Text.Contains([Vendor Name],"FIS ") then [#"FY20 - Jan"] * [#"ref_HC_Data_Actuals.% of Total 4"]

else if Text.StartsWith([Cost Center], "4") and Text.Contains([Vendor Name],"Investran") then [#"FY20 - Jan"] * [#"ref_HC_Data_Actuals.% of Total 4"]

else if Text.StartsWith([Cost Center], "4") and Text.Contains([Vendor Name],"DealCloud") then [#"FY20 - Jan"] * [#"ref_HC_Data_Actuals.% of Total 4"]

else if Text.StartsWith([Cost Center], "4") and Text.Contains([Vendor Name],"Sidley Austin") then [#"FY20 - Jan"] * [#"ref_HC_Data_Actuals.% of Total 4"]

else if Text.StartsWith([Cost Center], "4") and Text.Contains([Vendor Name],"ACA Compliance") then [#"FY20 - Jan"] * [#"ref_HC_Data_Actuals.% of Total 4"]

else if Text.StartsWith([Cost Center], "4") and Text.Contains([Vendor Name],"Steven Douglas Assoc. Interim Financial") then [#"FY20 - Jan"] * [#"ref_HC_Data_Actuals.% of Total 4"]

else if Text.StartsWith([Cost Center], "4") and [Account] = "62645" then [#"FY20 - Jan"] * [#"ref_HC_Data_Actuals.% of Total"]

else if Text.StartsWith([Cost Center], "4") and [Account] = "62650" then [#"FY20 - Jan"] * [#"ref_HC_Data_Actuals.% of Total"]

else if Text.StartsWith([Cost Center], "4") and [Account] = "62505" then [#"FY20 - Jan"] * [#"ref_HC_Data_Actuals.% of Total"]

else if Text.StartsWith([Cost Center], "4") and [Account] = "62510" then [#"FY20 - Jan"] * [#"ref_HC_Data_Actuals.% of Total"]

else if Text.StartsWith([Cost Center], "4") and [Account] = "62515" then [#"FY20 - Jan"] * [#"ref_HC_Data_Actuals.% of Total"]

else if Text.StartsWith([Cost Center], "4") and [Account] = "62520" then [#"FY20 - Jan"] * [#"ref_HC_Data_Actuals.% of Total"]

else [#"FY20 Jan Unallocated"])

1 REPLY 1
Anonymous
Not applicable

an impressive expression 😃

 

I don't know if my suggestion makes execution faster, but it sure is "prettier" 

 

 

 

 

let
    Origine = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("Pc0xDoMwDEbhq1ieWYqg7V1QhpTgP0YlsSgsPX2tpur6veFNEw8jd3zoWyuVRwaHzu3qNkcnrJDY7OYmECR6LZvttWht4f4NkESmZg3HiyOQMtnzPH7Wu1m0ZddSKUOa/l9bWTOH8AE=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [cc = _t, vn = _t]),
    #"Aggiunta colonna personalizzata" = Table.AddColumn(Origine, "func", each if Text.StartsWith([cc],"4") and List.Contains({"tizio","caio","pippo"}, [vn], (x)=>Text.Contains([vn],x)) then "it is" else "it isnt")
in
    #"Aggiunta colonna personalizzata"

 

 

Helpful resources

Announcements
Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

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.