Excel Formulas to Power Query formulas Help

Brass Contributor

I’m having troubles with the formulas I created in Excel then going to Power Query for my first time. After creating and modeling in Excel, I'm not sure how to go about making this possible in PQ. How do I go from an Excel formula to an M code equivalent?


  1. Use IF(OR( to determine type

=IF(OR(A2=999999,A2=444444),"Type 1","Type 2")


  1. Use the result of the first formula in an if and if false then VLOOKUP IF(VLOOKUP(. How Would I go from an IF with a false being an function (in this case VLOOKUP)?

=IFERROR(IF(D2="Type 1","Other",VLOOKUP(B2,Table2,2,0)),"-")


  1. Take a short date MM/DD/YYYY and get week number starting on Monday



  1. Mapping calendar days to conform to a 4-4-5 accounting calendar



  1. Know If data is from this year, last year, 2 years ago, 3 year ago, or older



Thank you!

2 Replies


Power Query has another logic, it's note necessary to map Excel formulas. First part could be as

    Source = Table1,
    #"Removed Other Columns" = Table.SelectColumns(Source,{"Account Number", "Sales Area #", "Date"}),
    #"Merged Queries" = Table.NestedJoin(
        #"Removed Other Columns", {"Sales Area #"},
        Table2, {"#"}, "Table2",
    #"Expanded Table2" = Table.ExpandTableColumn(#"Merged Queries", "Table2", {"Area"}, {"Area"}),
    #"Replaced Value" = Table.ReplaceValue(
        #"Expanded Table2",
        each [Area],
            if [Account Number]=999999 or [Account Number]=444444
            then "Other"
            else [Area],
    #"Inserted Week of Year" = Table.AddColumn(
        #"Replaced Value",
        "Week of Year",
        each Date.WeekOfYear([Date]), Int64.Type),
    #"Changed Type" = Table.TransformColumnTypes(#"Inserted Week of Year",{{"Date", type date}})
    #"Changed Type"

practically everything from UI. Not sure right now about other calendars, perhaps mapping tables could help.

@Sergei Baklan Thank you so much!


I wasn't at first mapping/creating everything in Excel first rather taking what I have in Excel then turning that in Power Query since I already finished and know this is what I want to get to.