Forum Discussion

visittokiran's avatar
visittokiran
Frequent Visitor
4 years ago
Solved

DATE AND TIME MATCHING WITH ERROR

I have following two tables with date & time table 

I want to fetch data in table A as shown below

 TABLE B  
CODEDATE & TIMEINCIDENT IDENTRY TYPE
H1234501/10/2021 08:0075769338A
H7679302/10/2021 08:0079879893B
H8797403/10/2021 08:00987979721 C
H8944804/10/2021 08:003628643E

 

TABLE A 
CODEDATE & TIME
H1234501/10/2021 08:15
H7679302/10/2021 08:30
H8797403/10/2021 08:20
H8944804/10/2021 08:05

Final result required 

TABLE A (FINAL)  DATA MATCHING WITH ERROR OF 30 MINS
CODEDATE & TIMEincidentENTRY TYPE
H1234501/10/2021 08:1575769338A
H7679302/10/2021 08:3079879893B
H8797403/10/2021 08:20987979721 C
H8944804/10/2021 08:053628643E
  • smpa01's avatar
    smpa01
    4 years ago

    visittokiran  you can create a measure like this and utilize this a visual level filter

     

    _filter = 
    VAR _a =CALCULATE(MAX('table A'[DATE & TIME]))
    VAR _b =CALCULATE(MAX('table B'[DATE & TIME]))
    VAR _c = ABS(DATEDIFF(_a,_b,MINUTE))
    RETURN switch(true(),_c=30||_c=0,1)

6 Replies

  • Hi visittokiran ,

     

    I'm not sure I fully understand your requirements here.

    It looks like [CODE] is a unique field in both tables, so why not just merge tableA with tableB on tableA[CODE] = tableB[CODE]?

     

    Pete

    • visittokiran's avatar
      visittokiran
      Frequent Visitor

      Sorry for late reply BA_Pete , you are right but sorry i did not mentioned that in that data there are multiple entried in a days for same code. In that case how to match data ? 

      • BA_Pete's avatar
        BA_Pete
        Super User

        visittokiran ,

         

        OK, no worries.

         

        Can you provide a more representative example of your data please?

        If you can create an example of tableA and tableB in Power Query (Enter Data) then just post the M code for each that would be ideal.

         

        Pete