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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
_Patrick
New Member

Help with adding column to table (one-to-many relationship filter)

Hello,

 

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).

 

 

_Patrick_0-1644254562516.png

 

 

_Patrick_1-1644254562524.png

 

 

 

_Patrick_2-1644254562524.png

 

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

_Patrick_3-1644254562527.png

 

Thanks in advance! 

 

2 ACCEPTED SOLUTIONS
serpiva64
Super User
Super User

Hi,

to obtain this table

serpiva64_1-1644271369865.png

 

you have to:

In Table B

- Group by 

serpiva64_2-1644271477441.png

- then add custom column

serpiva64_3-1644271619182.png

- expand Custom

serpiva64_4-1644271689631.png

and now Table B looks like this:

serpiva64_5-1644271772267.png

You can remove Column Count.

 

Then in Table A:

- Merge query

serpiva64_7-1644271939595.png

- and finally Expand Table B

serpiva64_8-1644271985712.png

If this post isuseful to help you to solve your issue consider giving the post a thumbs up and accepting it as a solution !

View solution in original post

_Patrick
New Member

Thanks for the suggestions! This is really helpful! Another way I discovered was to add a new column using DAX:

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])

View solution in original post

3 REPLIES 3
_Patrick
New Member

Thanks for the suggestions! This is really helpful! Another way I discovered was to add a new column using DAX:

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])

serpiva64
Super User
Super User

Hi,

to obtain this table

serpiva64_1-1644271369865.png

 

you have to:

In Table B

- Group by 

serpiva64_2-1644271477441.png

- then add custom column

serpiva64_3-1644271619182.png

- expand Custom

serpiva64_4-1644271689631.png

and now Table B looks like this:

serpiva64_5-1644271772267.png

You can remove Column Count.

 

Then in Table A:

- Merge query

serpiva64_7-1644271939595.png

- and finally Expand Table B

serpiva64_8-1644271985712.png

If this post isuseful to help you to solve your issue consider giving the post a thumbs up and accepting it as a solution !

KNP
Super User
Super User

Hi @_Patrick,

 

Depending on how the tables are built, one way to do this is to reference Table B/aggregate to max date/merge back with Table A.

See attached PBIX.

Hope this helps.

 

Have I solved your problem?
Please click Accept as Solution so I don't keep coming back to this post, oh yeah, others may find it useful also ;).
chrome-9xf-Zagzel-B

If you found this post helpful, please give Kudos.
It gives me a sense of instant gratification and, if you give me Kudos enough times, magical unicorns will appear on your screen.
If you find my signature vaguely amusing, please give Kudos.
KIfp67uy-Sr
Proud to be a Super User!PBI-Super-User-Rank-30x30-1x

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.