cancel
Showing results for 
Search instead for 
Did you mean: 

Fabric is Generally Available. Browse Fabric Presentations. Work towards your Fabric certification with the Cloud Skills Challenge.

Reply
Vrykolakas
Frequent Visitor

HELP ! Get Values from Another Table ( many-many relationship ) + New Column with Logical test

I've been struggling all day to get This result.
Due to the relationship between Table A and Table B, can't use Lookup, and the related() function is also showing me some issues. Maybe my logical thinking is the issue here... 

This is what I'm trying to achieve, I hope it's clear
2023-01-06_16h43_21.png

- Two new columns should be added to Table A, Season ( from Table B ) and StatusCurrent, that does a logical test to return True if Season = YEAR(TODAY())

1 ACCEPTED SOLUTION
v-zhangti
Community Support
Community Support

Hi, @Vrykolakas 

 

You can try the following methods. Add an index column to Table A in Power Query.

vzhangti_0-1673230600055.png

Column:

Season = 
Var _Maxseason=CALCULATE(MAX('Table B'[Season]),FILTER(ALL('Table B'),[id]=EARLIER('Table A'[id])))
Var _Maxindex=CALCULATE(MAX('Table A'[Index]),ALLEXCEPT('Table A','Table A'[id]))
Var _Minseason=CALCULATE(MIN('Table B'[Season]),FILTER(ALL('Table B'),[id]=EARLIER('Table A'[id])))
Return
IF([Index]=_Maxindex,_Maxseason,_Minseason)
StatusCurrent = IF(YEAR(TODAY())=[Season],TRUE(),FALSE())

vzhangti_1-1673231897716.png

Is this the result you expect?

 

Best Regards,

Community Support Team _Charlotte

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
v-zhangti
Community Support
Community Support

Hi, @Vrykolakas 

 

You can try the following methods. Add an index column to Table A in Power Query.

vzhangti_0-1673230600055.png

Column:

Season = 
Var _Maxseason=CALCULATE(MAX('Table B'[Season]),FILTER(ALL('Table B'),[id]=EARLIER('Table A'[id])))
Var _Maxindex=CALCULATE(MAX('Table A'[Index]),ALLEXCEPT('Table A','Table A'[id]))
Var _Minseason=CALCULATE(MIN('Table B'[Season]),FILTER(ALL('Table B'),[id]=EARLIER('Table A'[id])))
Return
IF([Index]=_Maxindex,_Maxseason,_Minseason)
StatusCurrent = IF(YEAR(TODAY())=[Season],TRUE(),FALSE())

vzhangti_1-1673231897716.png

Is this the result you expect?

 

Best Regards,

Community Support Team _Charlotte

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

lbendlin
Super User
Super User

For Many to x relationships you need to use RELATEDTABLE, not RELATED.

 

Please provide sample data that covers your issue or question completely.
https://community.powerbi.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-Forum/ba-...
Please show the expected outcome based on the sample data you provided.

https://community.powerbi.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447523

Helpful resources

Announcements
PBI November 2023 Update Carousel

Power BI Monthly Update - November 2023

Check out the November 2023 Power BI update to learn about new features.

Community News

Fabric Community News unified experience

Read the latest Fabric Community announcements, including updates on Power BI, Synapse, Data Factory and Data Activator.

Power BI Fabric Summit Carousel

The largest Power BI and Fabric virtual conference

130+ sessions, 130+ speakers, Product managers, MVPs, and experts. All about Power BI and Fabric. Attend online or watch the recordings.

Top Solution Authors
Top Kudoed Authors