Forum Discussion

davi_luc's avatar
davi_luc
Regular Visitor
3 years ago

Date column filter another table

Hello.

I'm having troubles filtering a table based on the selection of another table, so I would be able to calculate some measures.

My main table has two columns, ID and Date Order, wich are non unique. My secondary table has the same two columns, also with non unique values.

I would like to filter on the second table, for a given ID and Date Order, all the rows for that ID and wich the day diference betwen the Table A[Date Order] and Table B[Date Order] <= 5 and >= 0. 

To illustrate

 

 

2 Replies

  • davi_luc , we can copy the date from table to table to and take a diff and then use as diff

     

    a new measure

    Countx(Table2 ,

    var _col = maxx(filter(Table1, Table1[ID] = Table2[ID]), Table1[Date])

    var _diff = abs(datediff(Table2[Date], Table1[Date], Day) )

    return

    if(_diff <=5, Table2[ID], blank())

     

     

    in case you want create a column

    new column =

    var _col =maxx(filter(Table1, Table1[ID] = Table2[ID]), Table1[Date])

    return  abs(datediff(Table2[Date], Table1[Date], Day) )

    • davi_luc's avatar
      davi_luc
      Regular Visitor

      Hello amitchandak , thanks for your response.
      If I understood correctly, your answer won't work for me.
      In the example, if we look at Table A, ID = 1, we have two different dates, 15/01/2022 and 10/01/2022. The "allowed" dates, for ID = 1, in Table B, should be 5,6,7,8,9,10,11,12,13,14,15 of january.

      Your solution, since it uses a MAXX, would only allow the dates 10,11,12,13,14,15 of january.