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
peternznguyen
Helper II
Helper II

USERELATIONSHIP with MIN date not working as expected

 

Hi,

I have two tables Dim_Date and Fact_Inventory, they have Active relationship based on Dim_Date(DateSK) and Fact_Inventory(ReceivedDate_DateSK) and Inctive relationship based on Dim_Date(DateSK) and Fact_Inventory(ManufactureDate_DateSK).

 

The Active relationship works well, of course. However, when I want to get DateBK

from Dim_Date(DateBK) by the below DAX function to get ManufactureDate:

 

ManufactureDate = CALCULATE(
        MIN(Dim_Date[DateBK]),
        USERELATIONSHIP(Dim_Date[DateSK], Fact_Inventory[ManufacturedDate_DateSK])
)
 and it returns DataBK based on the Active relationship "Dim_Date(DateSK) and Fact_Inventory(ReceivedDate_DateSK)" but not the expecting Inactive relationship "Dim_Date(DateSK) and Fact_Inventory(ManufactureDate_DateSK)".
 

DateBK column is type Date (not DateTime)

 

(DateSK = Date Surrogate Key,  DataBK = Date Business Key)

 

Screenshots 
Describe the situation
peternznguyen_0-1680900912531.png

 

 and not expecting result

peternznguyen_2-1680901628125.png

==>The ManufactureDate should return 2023-04-05 based on its ManufactureDate_DateSK 20230405, but it returns 2023-04-07 that is same as ReceivedDate

 

 

Please help me out

Thank you in advance.

Peter

 

 

 
1 ACCEPTED SOLUTION
v-yiruan-msft
Community Support
Community Support

Hi @peternznguyen ,

Please update the formula of measure [ManufactureDate ] as below and check if you can get the expected result... Please find the details in the attachment.

ManufactureDate =
CALCULATE (
    MIN ( 'Fact_Inventory'[ManufactureDate_DateSK] ),
    FILTER (
        'Fact_Inventory',
        'Fact_Inventory'[ReceivedDate_DateSK]
            = SELECTEDVALUE ( 'Fact_Inventory'[ReceivedDate_DateSK] )
    )
)

vyiruanmsft_0-1681094117884.png

Best Regards

Community Support Team _ Rena
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-yiruan-msft
Community Support
Community Support

Hi @peternznguyen ,

Please update the formula of measure [ManufactureDate ] as below and check if you can get the expected result... Please find the details in the attachment.

ManufactureDate =
CALCULATE (
    MIN ( 'Fact_Inventory'[ManufactureDate_DateSK] ),
    FILTER (
        'Fact_Inventory',
        'Fact_Inventory'[ReceivedDate_DateSK]
            = SELECTEDVALUE ( 'Fact_Inventory'[ReceivedDate_DateSK] )
    )
)

vyiruanmsft_0-1681094117884.png

Best Regards

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

Helpful resources

Announcements
PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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