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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
rcb0325
Helper I
Helper I

Converting If/else statements from Excel

I have a table that I am trying to figure out the DAX input for. The formula in excel was: 

 

=if([Invoice Account]="112541",.11,IF([Customer Rebate Group]="TDG",.07,IF(OR([Invoice Account]="139871",[Invoice Account]="131324"),.08,.07)))

 

In Power BI, the table has a column of customer numbers, that I need to create a measure for to assign the values above to, so I can bring those in as another column. Can someone help me convert the excel formula? 

1 ACCEPTED SOLUTION
v-yalanwu-msft
Community Support
Community Support

Hi @rcb0325 ,


You could modify measure by the following formula:

Rebate Multiplier =
IF (
    MAX ( [BillToCustomerCustomerNumber] ) = "112541",
    .11,
    IF (
        MAX ( [BillToCustomerCustomerRebateGroup] ) = "TDG",
        .07,
        IF (
            MAX ( [BillToCustomerCustomerNumber] ) = "139871"
                || MAX ( [BillToCustomerCustomerNumber] ) = "131324",
            .08,
            .07)))
  

The final output is shown below:

v-yalanwu-msft_1-1621243199530.png

Best Regards,
Community Support Team_ Yalan Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

4 REPLIES 4
v-yalanwu-msft
Community Support
Community Support

Hi @rcb0325 ,


You could modify measure by the following formula:

Rebate Multiplier =
IF (
    MAX ( [BillToCustomerCustomerNumber] ) = "112541",
    .11,
    IF (
        MAX ( [BillToCustomerCustomerRebateGroup] ) = "TDG",
        .07,
        IF (
            MAX ( [BillToCustomerCustomerNumber] ) = "139871"
                || MAX ( [BillToCustomerCustomerNumber] ) = "131324",
            .08,
            .07)))
  

The final output is shown below:

v-yalanwu-msft_1-1621243199530.png

Best Regards,
Community Support Team_ Yalan Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

rcb0325
Helper I
Helper I

When I type out the DAX, and replace the fields with what they should be, it is not allowing me to use them. (highlighted below). 

 

Is there a certain format that the field has to be in? 

 

=IF([BillToCustomerCustomerNumber]="112541",.11,IF([BillToCustomerCustomerRebateGroup]="TDG",.07,IF(OR([BillToCustomerCustomerNumber]="139871",[BillToCustomerCustomerNumber]="131324"),.08,.07)))

 

Capture.JPG

Hi,

It should be written as a calculated column formula (not as a measure).  Also, the best practise is to precede the column name with the table name.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
Ashish_Mathur
Super User
Super User

Hi,

The calculated column formula should remain the same in DAX as well.  Just replace Invoice Account, Customer Rebate Group and Invoice Account with customer numbers.

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

Find out what's new and trending in the Fabric Community.

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

Check out the November 2024 Power BI update to learn about new features.