Forum Discussion

moliana's avatar
moliana
New Member
3 years ago
Solved

Create a new column based on Multiple Conditions

I have a daily data set whereby the data shows total in dollars for customer purchases. I am trying to create a column in Power Query that shows the delivery fee from each customer purchase, which is...
  • SamInogic's avatar
    3 years ago

    Hi moliana,

    In Power BI, you can create a column using Power Query based on multiple condition with below steps:

    • Add new Custom column from query editor and used below expression as follows Screenshot

    Custom = Table.AddColumn(#"Changed Type", "Custom", each if [#"Delivery Method "] = "Pickup" then "$0" else if Number.ToText([Branch ID])="2354" and [#"Delivery City "]="Warwick" then "$1.99" else if Number.ToText([Branch ID])="2386" and [#"Delivery City "]="Warwick" then "$6.09" else if Number.ToText([Branch ID])="2354" and [#"Delivery City "]="Hamilton" then "$7.09" else  if Number.ToText([Branch ID])="2386" and [#"Delivery City "]="Hamilton" then "$8.09" else "")

     

    This will result as shown in below screenshot:


    If this answer helps, please mark it as Accepted Solution so it would help others to find the solution.


    Thanks!

    Inogic Professional Service Division

    An expert technical extension for your techno-functional business needs

    Power Platform/Dynamics 365 CRM

    Drop an email at [email protected]

    Service:  http://www.inogic.com/services/ 

    Power Platform/Dynamics 365 CRM Tips and Tricks:  http://www.inogic.com/blog/