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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
psyclown
New Member

RELATED function not working with one-to-many relationship

Hi,

 

I've scratched my head for several days now, trying to figure out this problem with RELATED and one-to-many relationship.

 

My relationship:

psyclown_0-1624629448913.png

 

My measure:

Indeks salg = (1200000 / 365) * ((DATEDIFF(DATE(YEAR(Today()), 1, 1), Today(), DAY) - 1) - DATEDIFF(DATE(YEAR(Today()), "01", "01"), RELATED('Booking Administration'[IndexDate]), DAY))
 
Error: Column with name was not found ...
 
I can't seems figure out what the problem is or how to get around it.
Hopefully someone here can help me in right direction!
 
Best Regards,
Jesper
3 REPLIES 3
PaulOlding
Solution Sage
Solution Sage

Is Indeks salg a measure or calculated column?

 

If it's a measure then there's this issue:

You have the basic premise right in that RELATED will allow you to get a value from a dimension table (Booking Administration), but... you need to be iterating the fact table (Certus Bordereau) to do it.  You need a row context from the fact table, then RELATED will follow the relationship from the fact (for the current row) to the dimension and get the single value for your column.

Right now, you're not iterating the fact anywhere in your measure.

@PaulOlding 

Thanks for the quick response, both of you.

 

How can I supposed to iterate the fact table in this situation?

 

@amitchandak is mentioning making a column in the many table with the one tables value. I've tried that too and I can make a column in many (Certus Bordereau) with just:

 

column = RELATED('Booking Administration'[IndexDate])

 

But my understanding with using a date in a measure, then you need to have it wrapped by something like MAX, MIN, LASTDATE etc and I don't want that, since IndexDate is a unique value for each row in Booking Administration.

amitchandak
Super User
Super User

@psyclown , related work in one to many if you create a column on many sides from the one side Table.

 

On one side, you can try like this example 

 

MAxx(RELATEDTABLE('Booking Administration'), [IndexDate])

 

 

refer if needed, 4 ways to copy data from one table to another
https://www.youtube.com/watch?v=Wu1mWxR23jU
https://www.youtube.com/watch?v=czNHt7UXIe8

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.