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

The ultimate Microsoft Fabric, Power BI, Azure AI & SQL learning event! Join us in Las Vegas from March 26-28, 2024. Use code MSCUST for a $100 discount. Register Now

Reply
alice11987
Helper I
Helper I

Way to match exceptions mapping table

I have 2 tables: 

1. Mapping exceptions - this table contains 4 columns, [Level 02], [Level 03], [Level 04] and [Max Layer].

2. Employee Report - this table contains 3 columns, [Level 02], [Level 03], [Level 04] and I would like to add [Max Layer] column into this table.

 

Mapping Logic:

    Only the first row need to have all Level matches, the max layer = 9 ;

    For second row, as long as first 2 level matches, the max layer = 9 ;

    For last row, as long as the first level matches, the max layer = 9;

    if it doesn't match, default max layer should be 8.

 

alice11987_0-1701311275841.png

 

Any good way to match/merge?

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

Hi @alice11987 ,

First add an indexed column to the table 'Mapping exceptions':

vjunyantmsft_0-1701673204844.png

Then create a new column using the following DAX:

MAX Layer = 
VAR row1_col1 = LOOKUPVALUE('Mapping exceptions'[LEVEL 02], 'Mapping exceptions'[Index], 1)
VAR row1_col2 = LOOKUPVALUE('Mapping exceptions'[LEVEL 03], 'Mapping exceptions'[Index], 1)
VAR row1_col3 = LOOKUPVALUE('Mapping exceptions'[LEVEL 04], 'Mapping exceptions'[Index], 1)

VAR row2_col1 = LOOKUPVALUE('Mapping exceptions'[LEVEL 02], 'Mapping exceptions'[Index], 2)
VAR row2_col2 = LOOKUPVALUE('Mapping exceptions'[LEVEL 03], 'Mapping exceptions'[Index], 2)

VAR row3_col1 = LOOKUPVALUE('Mapping exceptions'[LEVEL 02], 'Mapping exceptions'[Index], 3)

RETURN
IF(
    ('Mapping Logic'[LEVEL 02] = row1_col1 && 'Mapping Logic'[LEVEL 03] = row1_col2 && 'Mapping Logic'[LEVEL 04] = row1_col3) ||
    ('Mapping Logic'[LEVEL 02] = row2_col1 && 'Mapping Logic'[LEVEL 03] = row2_col2) ||
    ('Mapping Logic'[LEVEL 02] = row3_col1),
    9,
    8
)

vjunyantmsft_1-1701673258301.png


Best Regards,
Dino Tao
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

1 REPLY 1
v-junyant-msft
Community Support
Community Support

Hi @alice11987 ,

First add an indexed column to the table 'Mapping exceptions':

vjunyantmsft_0-1701673204844.png

Then create a new column using the following DAX:

MAX Layer = 
VAR row1_col1 = LOOKUPVALUE('Mapping exceptions'[LEVEL 02], 'Mapping exceptions'[Index], 1)
VAR row1_col2 = LOOKUPVALUE('Mapping exceptions'[LEVEL 03], 'Mapping exceptions'[Index], 1)
VAR row1_col3 = LOOKUPVALUE('Mapping exceptions'[LEVEL 04], 'Mapping exceptions'[Index], 1)

VAR row2_col1 = LOOKUPVALUE('Mapping exceptions'[LEVEL 02], 'Mapping exceptions'[Index], 2)
VAR row2_col2 = LOOKUPVALUE('Mapping exceptions'[LEVEL 03], 'Mapping exceptions'[Index], 2)

VAR row3_col1 = LOOKUPVALUE('Mapping exceptions'[LEVEL 02], 'Mapping exceptions'[Index], 3)

RETURN
IF(
    ('Mapping Logic'[LEVEL 02] = row1_col1 && 'Mapping Logic'[LEVEL 03] = row1_col2 && 'Mapping Logic'[LEVEL 04] = row1_col3) ||
    ('Mapping Logic'[LEVEL 02] = row2_col1 && 'Mapping Logic'[LEVEL 03] = row2_col2) ||
    ('Mapping Logic'[LEVEL 02] = row3_col1),
    9,
    8
)

vjunyantmsft_1-1701673258301.png


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

Helpful resources

Announcements
Fabric Community Conference

Microsoft Fabric Community Conference

Join us at our first-ever Microsoft Fabric Community Conference, March 26-28, 2024 in Las Vegas with 100+ sessions by community experts and Microsoft engineering.

February 2024 Update Carousel

Power BI Monthly Update - February 2024

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

Fabric Career Hub

Microsoft Fabric Career Hub

Explore career paths and learn resources in Fabric.

Fabric Partner Community

Microsoft Fabric Partner Community

Engage with the Fabric engineering team, hear of product updates, business opportunities, and resources in the Fabric Partner Community.