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.
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
Input Table
Solved! Go to Solution.
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.
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] ) )
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
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.
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] ) )
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
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.
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
108 | |
105 | |
88 | |
74 | |
66 |
User | Count |
---|---|
126 | |
111 | |
100 | |
83 | |
71 |