Forum Discussion

Fcoatis's avatar
Fcoatis
Icon for Post Patron rankPost Patron
7 years ago
Solved

Contains

Hello,

I need to create a measure to check values against a virtual table like this:

 

Test = 
VAR currCustomer = VALUES(Customer[CustomerKey])
VAR TempTable = FILTER(InternetSales,InternetSales[OrderDate]<DATE(2011,1,1))
RETURN
IF(
    HASONEFILTER(InternetSales[CustomerKey]),
    CONTAINS(TempTable,Customer[CustomerKey],currCustomer),
    BLANK()
)

But every record returns false. What am I doing wrong? Sample is Here

 

Thanks in advance

  • Just replace ur measure with this;

    Test = 
    VAR currCustomer = SELECTEDVALUE(Customer[CustomerKey])
    VAR TempTable = FILTER(InternetSales,InternetSales[OrderDate]<DATE(2011,1,1))
    RETURN
    IF(
        CONTAINS(TempTable,Customer[CustomerKey],currCustomer),
        TRUE(),
        FALSE()
    )

4 Replies

    • Fcoatis's avatar
      Fcoatis
      Icon for Post Patron rankPost Patron

      tex628 Hi,

      I dont need date column. Only customer Key, Name and the measure. For those customers below it must return true


      • tex628's avatar
        tex628
        Icon for Community Champion rankCommunity Champion

        Just replace ur measure with this;

        Test = 
        VAR currCustomer = SELECTEDVALUE(Customer[CustomerKey])
        VAR TempTable = FILTER(InternetSales,InternetSales[OrderDate]<DATE(2011,1,1))
        RETURN
        IF(
            CONTAINS(TempTable,Customer[CustomerKey],currCustomer),
            TRUE(),
            FALSE()
        )