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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
F75
Advocate I
Advocate I

CALCULATETABLE with multiple filter

I am trying to lookup data in 'input' table for a intersecation in table 'Data'.

 

One of the dimensions 'scenario' is 'input' table is available as column, but the same dimension is available in rows in 'Data' table. How do i lookup values?

 

e.g. for Row 5, loookup value in data table should be

 

2017 Plan A|  Sales |.........| 1010 

 

 

Data table

 

data.JPG

 

 

Input Table

 

Input.JPG

 

 

 

1 ACCEPTED SOLUTION
v-yulgu-msft
Employee
Employee

Hi @F75,

 

If there are only a few columns in Input Table, like [2017 Plan A] and [2017 Plan B], you can use below formula to create a calculate column in Data Table.

New Unit Price =
IF (
    Data[Scenario] = "2017 Plan A",
    LOOKUPVALUE ( Input[2017 Plan A], Input[Account], Data[Account] ),
    IF (
        Data[Scenario] = "2017 Plan B",
        LOOKUPVALUE ( Input[2017 Plan B], Input[Account], Data[Account] ),
        BLANK ()
    )
)

However, if there are many columns in Input Table in query editor, you should first unpivot it to get below format.
1.PNG

Then, in modeling mode, based on above table, please create a new table.

Table =
UNION (
    SELECTCOLUMNS (
        'Input (2)',
        "Account", 'Input (2)'[Account],
        "Plan", 'Input (2)'[Attribute],
        "Value", 'Input (2)'[Value]
    ),
    SELECTCOLUMNS (
        'Input (2)',
        "Account", 'Input (2)'[Account],
        "Plan", 'Input (2)'[Attribute.1],
        "Value", 'Input (2)'[Value.1]
    )
)

2.PNG

 

Then, in Data Table, create a calculated column.

New Unit Price 2 =
LOOKUPVALUE (
    'Table'[Value],
    'Table'[Account], Data[Account],
    'Table'[Plan], Data[Scenario]
)

Best regards,
Yuliana Gu

Community Support Team _ Yuliana Gu
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-yulgu-msft
Employee
Employee

Hi @F75,

 

If there are only a few columns in Input Table, like [2017 Plan A] and [2017 Plan B], you can use below formula to create a calculate column in Data Table.

New Unit Price =
IF (
    Data[Scenario] = "2017 Plan A",
    LOOKUPVALUE ( Input[2017 Plan A], Input[Account], Data[Account] ),
    IF (
        Data[Scenario] = "2017 Plan B",
        LOOKUPVALUE ( Input[2017 Plan B], Input[Account], Data[Account] ),
        BLANK ()
    )
)

However, if there are many columns in Input Table in query editor, you should first unpivot it to get below format.
1.PNG

Then, in modeling mode, based on above table, please create a new table.

Table =
UNION (
    SELECTCOLUMNS (
        'Input (2)',
        "Account", 'Input (2)'[Account],
        "Plan", 'Input (2)'[Attribute],
        "Value", 'Input (2)'[Value]
    ),
    SELECTCOLUMNS (
        'Input (2)',
        "Account", 'Input (2)'[Account],
        "Plan", 'Input (2)'[Attribute.1],
        "Value", 'Input (2)'[Value.1]
    )
)

2.PNG

 

Then, in Data Table, create a calculated column.

New Unit Price 2 =
LOOKUPVALUE (
    'Table'[Value],
    'Table'[Account], Data[Account],
    'Table'[Plan], Data[Scenario]
)

Best regards,
Yuliana Gu

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

Thanks @v-yulgu-msft and @parry2k

parry2k
Super User
Super User

I would recommend to unpivot your input table and then joint to you data table and the pivot it back (if required)



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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