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

Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!

Reply
Anonymous
Not applicable

Compare two dates from different tables from DataSet, DaxStudio

Hi, I am trying to compare two dates from different tables, I was trying to use Related function, but it does not work. 

Are you able to help me with this topic? I am using DataSet, with tables and measures. 

 

DEFINE
 // COLUMN 'Delivery Date'[CompareDates] = DATEDIFF('Delivery Date'[DLVD Date],RELATED('Reception Date'[RCTD Date]),Day)
    VAR filter_1 =
        FILTER (
            VALUES ( 'Material'[MAT Business ID] ),
            'Material'[MAT Business ID] = "XX"
        )
    VAR filter_2 =
        FILTER (
            VALUES ( 'Creditor Supplier'[POCS Description] ),
            ( 'Creditor Supplier'[POCS Description] <> "XX" )
                && ( 'Creditor Supplier'[POCS Description] <> "YY" ))
              
EVALUATE
SUMMARIZECOLUMNS (
    'Material'[MAT Business ID],
    'Delivery Date'[DLVD Year-Week],
    'Purchase Order'[PO Number],
    'Delivery Date'[DLVD Date],
    'Reception Date'[RCTD Date],
  //  'Delivery Date'[CompareDates],
    'Material'[MAT Supplier Id],
    'Manufacturer'[MAN Description],
    filter_1,
    filter_2,
    "Purchase Order Ordered Quantity", [Purchase Order Ordered Quantity]
)

 

Error:

NewUserHI21_0-1658218404360.png

 

1 REPLY 1
v-chenwuz-msft
Community Support
Community Support

Hi @Anonymous ,

 

You need create a relationship between 'Delivery Date' and 'Reception Date' when use RELATED() function. 

Or you can try another way to get the related date. Some dax like the following:

DATEDIFF (
    'Delivery Date'[DLVD Date],
    MAXX (
        FILTER (
            'Reception Date',
            [RCTD Date] = EARLIER ( 'Delivery Date'[DLVD Date] )
        ),
        [RCTD Date]
    ),
    DAY
)

 

Best Regards

Community Support Team _ chenwu zhu

 

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

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

Vote for your favorite vizzies from the Power BI World Championship submissions!

Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.