Forum Discussion

DionTN's avatar
DionTN
Helper II
4 years ago
Solved

Add column based on double filter

I have two tables like this: 

CompanyStartDateEndDateRegio
a01/01/202008/08/2020Demo
b01/01/202008/08/2020Demo
c01/01/202008/08/2020Demo
d01/01/202008/08/2020Demo
d08/01/202008/10/2020Live
d10/10/202001/12/2020Test
e01/01/202008/08/2020Demo
f01/01/202008/08/2020Demo
g01/01/202008/08/2020Demo

 

CompanyLoginDateregio
a02/01/2020demo
a03/01/2020demo
b04/01/2020demo
b05/01/2020demo
c06/01/2020demo
c07/01/2020demo
d11/11/2020test
d09/01/2020demo
d10/01/2020demo
e11/01/2020demo

 

I need to add the regio in the second table by a double filter in the first table. 

So I need to check the company and if the LoginDate is between start and end time. If so add regio to the second table. 

 

How can i write the function in add column? 

  • Hi DionTN 

     

    Can you try as below please?

    Column = 
    
    CALCULATE
        (
            SELECTEDVALUE(Table1[Regio]),
            FILTER
                (
                    Table1,
                    Table1[Company] = Table2[Company] &&
                    Table1[StartDate] <= Table2[LoginDate] &&
                    Table1[EndDate] >= Table2[LoginDate]
                )
        )
    

     

     

1 Reply

  • Hi DionTN 

     

    Can you try as below please?

    Column = 
    
    CALCULATE
        (
            SELECTEDVALUE(Table1[Regio]),
            FILTER
                (
                    Table1,
                    Table1[Company] = Table2[Company] &&
                    Table1[StartDate] <= Table2[LoginDate] &&
                    Table1[EndDate] >= Table2[LoginDate]
                )
        )