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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
mohsenask
Helper II
Helper II

Multiple IF ELSE across two tables

Hi all,

 

I have two tables - M_fees which as below and another table of transactions (All_Fees) for the company with multiple fields

 

Screenshot 2021-11-07 at 17.21.01.png

 

I want to create a calculated column in the All_fees transaction table which will check each record for the following conditions;

i.e. Fees_applicable = if All_Fees[Brand_ID] and All_Fees[Fee_Type] and All_fees[Is_Premium] and All_Fees[company name]
THEN M_fees[Perc_Amt] or M_fees[Value]

i dont seem to understand how to use IF ELSE statements across two tables.

 

Please help

 

@amitchandak 

 

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

Hi, @mohsenask 

 

You can use the LOOKUPVALUE function to help you.

I have to say that the company names in your tables are not the same, which makes me keep my formula continuously failing.

vangzhengmsft_0-1636512144951.png

And the case of the fields in the table is best to be the same, you can transform the case of the field in PowerQuery.

vangzhengmsft_1-1636512351517.png

Okay, what we have to do next is to create a calculated column as follows:

 

Column = 
VAR _A=
LOOKUPVALUE(
    M_fees[PERC_AMT],
    M_fees[COMPANY NAME],All_Fees[MetadataCompany],
    M_fees[BRAND_ID],All_Fees[card_ brand],
    // M_fees[IS_Premium],All_Fees[IS._Premeium]
    M_fees[IS_ PREMIUM],All_Fees[C. _Premium]
   )
VAR _B="IF A = BLANK THEN B ELSE A"
RETURN _A
// The value of VALUE column in M_fees table is blank, if you want just blankvalue, you don't need the VAR _B

 

Result:

vangzhengmsft_2-1636512449542.png

Since the data above doesn't have a value that can be matched so I added four extra rows.

 

And in your table, if you want to do it with a measure, it would be helpful if the Boolean value can be converted to 0 and 1. You can change your source data, or add a calculated column to display the Boolean value as a number.

The calculated column looks like this:

 

IS._Premeium = [C. _Premium]+0

 

 

Please refer to the attachment below for details. Hope this helps.

 

 

Best Regards,
Community Support Team _ Zeon Zheng


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

3 REPLIES 3
v-angzheng-msft
Community Support
Community Support

Hi, @mohsenask 

 

You can use the LOOKUPVALUE function to help you.

I have to say that the company names in your tables are not the same, which makes me keep my formula continuously failing.

vangzhengmsft_0-1636512144951.png

And the case of the fields in the table is best to be the same, you can transform the case of the field in PowerQuery.

vangzhengmsft_1-1636512351517.png

Okay, what we have to do next is to create a calculated column as follows:

 

Column = 
VAR _A=
LOOKUPVALUE(
    M_fees[PERC_AMT],
    M_fees[COMPANY NAME],All_Fees[MetadataCompany],
    M_fees[BRAND_ID],All_Fees[card_ brand],
    // M_fees[IS_Premium],All_Fees[IS._Premeium]
    M_fees[IS_ PREMIUM],All_Fees[C. _Premium]
   )
VAR _B="IF A = BLANK THEN B ELSE A"
RETURN _A
// The value of VALUE column in M_fees table is blank, if you want just blankvalue, you don't need the VAR _B

 

Result:

vangzhengmsft_2-1636512449542.png

Since the data above doesn't have a value that can be matched so I added four extra rows.

 

And in your table, if you want to do it with a measure, it would be helpful if the Boolean value can be converted to 0 and 1. You can change your source data, or add a calculated column to display the Boolean value as a number.

The calculated column looks like this:

 

IS._Premeium = [C. _Premium]+0

 

 

Please refer to the attachment below for details. Hope this helps.

 

 

Best Regards,
Community Support Team _ Zeon Zheng


If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Fowmy
Super User
Super User

@mohsenask 

Your question is not clear, can you share the expected output and mention if your tables are connected:

An example of IF:

Price Group =
IF(
    'Product'[List Price] < 500,
    "Low",
    IF(
        'Product'[List Price] < 1500,
        "Medium",
        "High"
    )
)

 

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

@Fowmy Thanks for the quick reply

 

Im creating a new column in the below visual where I want to check the multiple column values in the below table will bring me the value.......

mohsenask_0-1636293441375.png

.........of the Perc_Amt from the below highlighted table; 

 

Screenshot 2021-11-07 at 17.21.01.png

Helpful resources

Announcements
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!

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

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