Home > OS >  Power BI - Help adding new column to table using many side of one-to-many relationship
Power BI - Help adding new column to table using many side of one-to-many relationship

Time:02-08

Can someone please confirm if the following is achievable using Power BI? I have two tables that have a One-to-many relationship. I am trying to add a new column to Table A (one) which will contain the most recent Event Name from Table B (many).

Relationship

Table A (one)

Table B (many)

Desired output - new column on Table A which contains the latest most recent Value from the Many side.

Desired output - new column added to Table A

Thanks in advance!

CodePudding user response:

If you need a CalculateColumn (in table A):

enter image description here

LatestEvent = var _id = [ID]
var _lastDate = CALCULATE(MAX('Table B'[Date]),'Table B'[ID] = _id)
return
calculate( MAX('Table B'[Name]),'Table B'[Date] = _lastDate && _id = 'Table B'[ID])

If you need a measure:

MeasureLatestEvent = var _id = SELECTEDVALUE('Table A'[ID])
var _lastDate = CALCULATE(MAX('Table B'[Date]),'Table B'[ID] = _id)
return
calculate( MAX('Table B'[Name]),'Table B'[Date] = _lastDate && _id = 'Table B'[ID])
  •  Tags:  
  • Related