Forum Discussion

scott_Abaana's avatar
scott_Abaana
Helper I
5 years ago
Solved

Combining Columns or replacing

Hi,  So I am building a reporting system based on power Query and I am just learning the basics at the moment.  Its pretty complex when put together. As part of this I am dealing with different payer...
  • edhans's avatar
    edhans
    5 years ago

    I'd really call that doing it from the Ribbon scott_Abaana - you want several if/then/else constructs. If you can do nested IF() functions in Excel (or IFS()) then you can do this.

    From the ribbon, go to Add Columns, then Custom Column, and type in this formula:

    if [FREQ] = "Cash" then [Amount] else if [FREQ] = "Yearly" then [Amount] else if [FREQ] = "Monthly" then [Amount] * 12 else if [FREQ] = "Quarterly" then [Amount] * 4 else null

    So intead of creating all of the columns, you just do the math on the [Amount] field.

     

    The if/then/else construct is a bit different than Excel.

    • the keywords if, then, and else are always lowercase
    • All three are required. Excel lets you leave the last one out and you can do =IF(A1=5,3) and that will return a blank if A1 doesn't equal 5 in Excel. In Power Query, if [Field] = 5 then 3 will return an error because else is missing.  I used else null for your final answer, but you can return the 9999999 if you want.

    Here is your workbook back. Look at my Single if then else query.