Forum Discussion
Show values on table based on columns from another table
Hello
Im having some issues generating a table, hopefully I can get some guidance on how to solve this issue. I would be greatly appreciate it.
Im trying to get the values from "Table B" to be shown on "Table A". My two tables have a relationship based on Date. However when I try to add to "Table A" the values of column "Parts Planned" I get the sum of all the rows on that colum since I can not find a way to relate those values based on part number.
| Table A | ||
| Date | part number | Parts Produced |
| 1/1/2025 | A | 50 |
| 1/1/2025 | B | 100 |
| 4/2/2025 | B | 50 |
| 4/2/2025 | C | 25 |
| 8/24/2025 | C | 5 |
| 12/8/2025 | D | 100 |
| 12/8/2025 | A | 150 |
| Table B | ||
| Date | part number | Parts Planned |
| 1/1/2025 | A | 100 |
| 1/1/2025 | B | 150 |
| 4/2/2025 | B | 200 |
| 4/2/2025 | C | 250 |
| 8/24/2025 | C | 50 |
| 12/8/2025 | D | 150 |
| 12/8/2025 | A | 200 |
This will be my desired result:
| Table A | |||
| Date | part number | Parts Produced | Parts Planned |
| 1/1/2025 | A | 50 | 100 |
| 1/1/2025 | B | 100 | 150 |
| 4/2/2025 | B | 50 | 200 |
| 4/2/2025 | C | 25 | 250 |
| 8/24/2025 | C | 5 | 50 |
| 12/8/2025 | D | 100 | 150 |
| 12/8/2025 | A | 150 | 200 |
However, this is what I get when I try to do sumx calculations
| Table A | |||
| Date | part number | Parts Produced | Parts Planned |
| 1/1/2025 | A | 50 | 1100 |
| 1/1/2025 | B | 100 | 1100 |
| 4/2/2025 | B | 50 | 1100 |
| 4/2/2025 | C | 25 | 1100 |
| 8/24/2025 | C | 5 | 1100 |
| 12/8/2025 | D | 100 | 1100 |
| 12/8/2025 | A | 150 | 1100 |
Any ideas?
Thanks in advance for the support!
This is an efficient solution and works when you can only choose 1 date. If there is a need to select multiple dates then try:
Parts Planned =
CALCULATE(
SUM('TableB'[Parts Planned]),
TREATAS(
VALUES('TableA'[Date]),
'TableB'[Date]
),
TREATAS(
VALUES('TableA'[part number]),
'TableB'[part number]
)
)
5 Replies
- ZanquetaSuper User
Hi limonSerga,
I tested here and worked. Please try from your side and let me know if it worked.
Parts Planned = LOOKUPVALUE( TableB[Parts Planned], TableB[Date], SELECTEDVALUE(TableA[Date]), TableB[part number], SELECTEDVALUE(TableA[part number]) )If this response was helpful in any way, I’d gladly accept a 👍much like the joy of seeing a DAX measure work first time without needing another FILTER.
Please mark it as the correct solution. It helps other community members find their way faster (and saves them from another endless loop 🌀.
- SmithoRegular Visitor
This is an efficient solution and works when you can only choose 1 date. If there is a need to select multiple dates then try:
Parts Planned =
CALCULATE(
SUM('TableB'[Parts Planned]),
TREATAS(
VALUES('TableA'[Date]),
'TableB'[Date]
),
TREATAS(
VALUES('TableA'[part number]),
'TableB'[part number]
)
)- limonSergaRegular Visitor
Smitho
Thanks a lot for the support. I was able to make it work in my model!
- SmithoRegular Visitor
Your relationship is based on date only. What you actually need is a match on date and Part Number. An easy solution is to concatenate date and part number in both tables (composite key). You can create a calculated column witth
Parts Planned =
LOOKUPVALUE(
'Table B'[Parts Planned],
'Table B'[Date], 'Table A'[Date],
'Table B'[part number], 'Table A'[part number]
)
- Hans-Georg_PulsSuper User
Hi limonSerga ,
there might be two reason for you result:
- Could it be that an implicit summarrization is defined for "Parts Planned". Please check if
- There is a sum sign in front of the your "Parts Planned" column in Data view
- You can deactivate that summarization by selecting the column and choose Summarization = "Don't summarize" from "Column tools" menu
- In Build view sum is activated as summarization for "Parts Planned"
- You can deactivate the summarization directly in the Data window changing the Summmarization entry
- There is a sum sign in front of the your "Parts Planned" column in Data view
- You mentioned "However, this is what I get when I try to do sumx calculations". Where do you do a sumx calculation? I wouldn't expect that you need any sum or sumx calculation to get what you want.
Hope that helps.
- Could it be that an implicit summarrization is defined for "Parts Planned". Please check if