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
defisher
New Member

Mapping Trouble with One to Many Relationship

I have a purchase table that contains a tax1 and tax2 field for each purchase of a specific item. This table is the only source for the tax1 and tax2 fields.
I also have a lookup table that contains the base price of each item.
I have these tables connected in a one to many relationship on an "item id" field.
I want to do some kind calculated column/measure in my lookup table such as "tax1_lookup = calculate(min(tax1), purchases.item_id = lookup.item_id)". The idea is I just want to grab of the tax values from the purchases table so I can move that field to my lookup table. Perferably, I would like to get the tax value for the most recent purchase (using purchase date) for each serial number, but just getting any of the tax values would be good enough to start.

 

1 ACCEPTED SOLUTION
v-yulgu-msft
Employee
Employee

Hi @defisher,

 

Add a calculated column in purchase table.

most recent tax1 =
CALCULATE (
    MAX ( Purchase[tax1] ),
    FILTER (
        ALLEXCEPT ( Purchase, Purchase[Itemid] ),
        Purchase[Date]
            = CALCULATE ( MAX ( Purchase[Date] ), ALLEXCEPT ( Purchase, Purchase[Itemid] ) )
    )
)

1.PNG

 

Add a calculated column in LookUp table.

Tax1 = LOOKUPVALUE(Purchase[most recent tax1],Purchase[Itemid],Lookup[Itemid])

2.PNG

 

Best regards,

Yuliana Gu

Community Support Team _ Yuliana Gu
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

1 REPLY 1
v-yulgu-msft
Employee
Employee

Hi @defisher,

 

Add a calculated column in purchase table.

most recent tax1 =
CALCULATE (
    MAX ( Purchase[tax1] ),
    FILTER (
        ALLEXCEPT ( Purchase, Purchase[Itemid] ),
        Purchase[Date]
            = CALCULATE ( MAX ( Purchase[Date] ), ALLEXCEPT ( Purchase, Purchase[Itemid] ) )
    )
)

1.PNG

 

Add a calculated column in LookUp table.

Tax1 = LOOKUPVALUE(Purchase[most recent tax1],Purchase[Itemid],Lookup[Itemid])

2.PNG

 

Best regards,

Yuliana Gu

Community Support Team _ Yuliana Gu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

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.