Forum Discussion
hugomatos
1 year agoNew Member
Creating new column based on value from another table
Hi everyone, I have 2 tables and I need to create a column on the second based on values from the first. Some ideia? table1 START CODE END CODE INFO 7100000 72000...
- 1 year ago
You could create a calculated DAX Column on table 2 for this. You would could create an ID for your code ranges and add them to your table1. Then with your caclulated column calculate what ID to assign each row and then relate the ID of table1 to the calculated ID of table2 Something like:
VAR RowID = Table2[ID]
VAR FilteredTable =
FILTER('Table1',
AND('Table1'[StartCode] <= RowID,
'Table1'[EndCode] >=RowID
)
)
VAR Result =
CALCULATE(
DISTINCT('Table1'[IDRangeKey]), FilteredTable)
RETURN ResultOnce that is created you can access that info column through the newly created relationship
- 1 year ago
Hi,
Please check the below picture and the attached pbix file.
expected result CC = SUMMARIZE ( FILTER ( Table1, Table1[START CODE] <= Table2[ID] && Table1[END CODE] >= Table2[ID] ), Table1[INFO] ) - 1 year ago
Hi hugomatos
Can you please try the below DAX.New Column =VAR MatchingRow =FILTER(table1,Table1[START CODE ] <= Table2[ID] &&Table2[ID] <= Table1[END CODE ])RETURNMAXX(MatchingRow, Table1[INFO])
If you have found your answer, please mark it as the solution.
sevenhills
1 year agoSuper User
Try this, add column to Table2:
Column = SUMMARIZE( FILTER( Table1, Table2[ID] >= Table1[START CODE] && Table2[ID] <= Table1[END CODE]), Table1[INFO])
Output: (Table 2)