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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
engingee
Helper I
Helper I

complex fomula transfer from Excel to Power BI edit query

Hi everyone, 

I currently have this formula in Excel and would like to wirte it in Power BI and give me the colunm result, I have tried condition column in query editor, but it it not working, can everyone help please, thanks in advance, the fomula (logic) is showing below, 

Firstly, I have 2 tabs, in Excel:

Tab1

Tab2

Formula in excel

=IFERROR(IFS(

Tab1 column A="one",VLOOKUP(Tab1 column B , 'Tab2'!$B$5:$C$75,2,FALSE),

Tab1 column A ="two",VLOOKUP(Tab1 column B, 'Tab2'!$B$76:$C$125,2,FALSE),

Tab1 column A ="three",VLOOKUP(Tab1 column B, 'Tab2'!$B$126:$C$149,2,FALSE),

Tab1 column A ="four",VLOOKUP(Tab1 column B,'Tab2'!$B$150:$C$191,2,FALSE)),

" Not Categorized")

 

1 ACCEPTED SOLUTION

Hi, @engingee 

It seems that you want to search for the corresponding value in the four areas of Tab2.

2.1.png
If so, you can first split  Tab2 into 4 separate tables (Tab2.1,Tab2.2,Tab2.3,Tab2.4).
(Select the range in excel->Create table->rename table name.
Newly created tables can  be found in the 'Navigation' when you connect to the excel file)

1.5.png

Then you can create a calculated column in Tab1 as below:
Dax:

Result =
IFERROR (
    SWITCH (
        Tab1[ColumnA],
        "one", LOOKUPVALUE ( Tab2.1[ColumnC], Table2.1[ColumnB], Tab1[ColumnB] ),
        "two", LOOKUPVALUE ( Table2.2[ColumnC], Table2.2[ColumnB], Tab1[ColumnB] ),
        "three", LOOKUPVALUE ( Table2.3[ColumnC], Table2.3[ColumnB], Tab1[ColumnB] ),
        "four", LOOKUPVALUE ( Table2.4[ColumnC], Table2.4[ColumnB], Tab1[ColumnB] )
    ),
    "Not category"
)

Best Regards,
Community Support Team _ Eason
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

7 REPLIES 7
aj1973
Community Champion
Community Champion

Hi @engingee 

You wouldn't need to use VLOOKUP in Power BI once you import your 2 Tabs. The relationship between the 2 Tabs will be created in Power BI and you will be able to add your column or your Pivot table. 

Regards
Amine Jerbi

If I answered your question, please mark this thread as accepted
and you can follow me on
My Website, LinkedIn and Facebook

thanks for your answer, but still a bit confused because both Tab1 column A and colunm B, and Tab 2 colunm B and colunm C have duplicated values🤔

Hi, @engingee 

It seems that you want to search for the corresponding value in the four areas of Tab2.

2.1.png
If so, you can first split  Tab2 into 4 separate tables (Tab2.1,Tab2.2,Tab2.3,Tab2.4).
(Select the range in excel->Create table->rename table name.
Newly created tables can  be found in the 'Navigation' when you connect to the excel file)

1.5.png

Then you can create a calculated column in Tab1 as below:
Dax:

Result =
IFERROR (
    SWITCH (
        Tab1[ColumnA],
        "one", LOOKUPVALUE ( Tab2.1[ColumnC], Table2.1[ColumnB], Tab1[ColumnB] ),
        "two", LOOKUPVALUE ( Table2.2[ColumnC], Table2.2[ColumnB], Tab1[ColumnB] ),
        "three", LOOKUPVALUE ( Table2.3[ColumnC], Table2.3[ColumnB], Tab1[ColumnB] ),
        "four", LOOKUPVALUE ( Table2.4[ColumnC], Table2.4[ColumnB], Tab1[ColumnB] )
    ),
    "Not category"
)

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

Hi @v-easonf-msft ,

Thanks for you answer, I just wondering if that any ways I can write your calculate colunms DAX into Custom Column in Power Query Editor please? Many thanks!

Hi, @engingee 

Dax and M query are not similar. It can be difficulte to convert DAX into custom column.

Please share the data of your two tables so that I can make a sample for your reference.

 

Best Regards,
Community Support Team _ Eason

Hi @v-easonf-msft thanks for you explain, I think I better try to work out as DAX as you suggested at this stage, and then the custom colunm.

aj1973
Community Champion
Community Champion

I see and I think you will need to create a bridge table containing column B only without duplicates then relate all 3 Tables together through 1 to many relationships 

Regards
Amine Jerbi

If I answered your question, please mark this thread as accepted
and you can follow me on
My Website, LinkedIn and Facebook

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors