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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
Hemansi
Frequent Visitor

FILTER NOT CONTAIN in calculate DAX Function

I needed your help with a DAX measure. I am trying to link two tables that unfortunately does not have primary or foreign key. I have Call Data and Sales Data and I need to match every sale to the calls that were sale. Here is the code I've used;

 

CallID =
    --Filter Dialler Data with Time Ranges
    VAR _2MinRangeFILTER(WinbackRawData,AND(WinbackRawData[Time]<=(JEMData[Time]+TIME(0,2,0)),WinbackRawData[Time]>=(JEMData[Time])-TIME(0,2,0)))
    VAR _5MinRangeFILTER(WinbackRawData,AND(WinbackRawData[Time]<=(JEMData[Time]+TIME(0,5,0)),WinbackRawData[Time]>=(JEMData[Time])-TIME(0,5,0)))
    VAR _10MinRangeFILTER(WinbackRawData,AND(WinbackRawData[Time]<=(JEMData[Time]+TIME(0,10,0)),WinbackRawData[Time]>=(JEMData[Time])-TIME(0,10,0)))
    VAR _15MinRangeFILTER(WinbackRawData,AND(WinbackRawData[Time]<=(JEMData[Time]+TIME(0,15,0)),WinbackRawData[Time]>=(JEMData[Time])-TIME(0,15,0)))
    --Lookup CallID for matching AgentName, Date, PhoneNumber constraining Classifications to Sales
    VAR _CallID1 =
        LOOKUPVALUE(
            WinbackRawData[CallID],
            WinbackRawData[AgentName],JEMData[AgentName],
            WinbackRawData[Date], JEMData[Date],
            WinbackRawData[PhoneNumber],JEMData[PhoneNumber],
            WinbackRawData[ClassificationType],"Sales",0)
    --Lookup CallID for matching AgentName, Completed Date&Time, PhoneNumber constraining AgentClassifications to Completed
    VAR _CallID2 =
        CALCULATE(    
            FIRSTNONBLANK(WinbackRawData[CallID], 1),
            FILTER(WinbackRawData,JEMData[AgentName]=WinbackRawData[AgentName]),
            FILTER(WinbackRawData,JEMData[C.Date]=WinbackRawData[Date]),
            FILTER(WinbackRawData,JEMData[PhoneNumber]=WinbackRawData[PhoneNumber]),
            FILTER(WinbackRawData, WinbackRawData[AgentClassification]="Completed"),
            FILTER(WinbackRawData,AND(WinbackRawData[Time]<=(JEMData[C.Time]+TIME(0,10,0)),WinbackRawData[Time]>=(JEMData[C.Time])-TIME(0,10,0))))
    VAR _Result1IF(_CallID1=0,_CallID2,_CallID1)
    --Get FirstCallID for matching AgentName, Date and Time with 4 mins Range constraining Classifications to Sales
    VAR _CallID2MinRange =
        CALCULATE(
            FIRSTNONBLANK(WinbackRawData[CallID],1),
            FILTER(WinbackRawData,NOT(CONTAINSROW({_Result1},WinbackRawData[CallID]))),
            FILTER(WinbackRawData,JEMData[AgentName]=WinbackRawData[AgentName]),
            FILTER(WinbackRawData,JEMData[Date]=WinbackRawData[Date]),
            FILTER(WinbackRawData, WinbackRawData[ClassificationType]="Sales"),
            _2MinRange)
    --Get FirstCallID for matching AgentName, Date and Time with 10 mins Range constraining Classifications to Sales
    VAR _CallID5MinRange =
        CALCULATE(
            FIRSTNONBLANK(WinbackRawData[CallID],1),
            FILTER(WinbackRawData,NOT(CONTAINSROW({_Result1},WinbackRawData[CallID]))),
            FILTER(WinbackRawData,JEMData[AgentName]=WinbackRawData[AgentName]),
            FILTER(WinbackRawData,JEMData[Date]=WinbackRawData[Date]),
            FILTER(WinbackRawData, WinbackRawData[ClassificationType]="Sales"),
            _5MinRange)
    --Get FirstCallID for matching AgentName, Date and Time with 20 mins Range constraining Classifications to Sales
    VAR _CallID10MinRange =
        CALCULATE(
            FIRSTNONBLANK(WinbackRawData[CallID],1),
            FILTER(WinbackRawData,NOT(CONTAINSROW({_Result1},WinbackRawData[CallID]))),
            FILTER(WinbackRawData,JEMData[AgentName]=WinbackRawData[AgentName]),
            FILTER(WinbackRawData,JEMData[Date]=WinbackRawData[Date]),
            FILTER(WinbackRawData, WinbackRawData[ClassificationType]="Sales"),
            _10MinRange)
    --Get FirstCallID for matching AgentName, Date and Time with 30 mins Range constraining Classifications to Sales
    VAR _CallID15MinRange =
        CALCULATE(
            FIRSTNONBLANK(WinbackRawData[CallID],1),
            FILTER(WinbackRawData,NOT(CONTAINSROW({_Result1},WinbackRawData[CallID]))),
            FILTER(WinbackRawData,JEMData[AgentName]=WinbackRawData[AgentName]),
            FILTER(WinbackRawData,JEMData[Date]=WinbackRawData[Date]),
            FILTER(WinbackRawData, WinbackRawData[ClassificationType]="Sales"),
            _15MinRange)
    VAR _Result2IF(_Result1=BLANK(),_CallID2MinRange,_Result1)
    VAR _Result3IF(_Result2=BLANK(),_CallID5MinRange,_Result2)
    VAR _Result4IF(_Result3=BLANK(),_CallID10MinRange,_Result3)
    VAR _Result5IF(_Result4=BLANK(),_CallID15MinRange,_Result4)
RETURN
    _Result5


However, I keep getting duplicate values and I want every variable to lookup value that was not an outcome already from previous result. I have tried using the highlighted red text above but it keeps giving me error, Is there anything else I could use or do?
 
1 ACCEPTED SOLUTION
Mahesh0016
Super User
Super User

@Hemansi   FILTER(WinbackRawData,NOT (WinbackRawData[CallID]  IN{_Result1} ))
For E.g :
Price =
CALCULATE (
SUM ( Bike[Price] ),
FILTER ( Bike, NOT ( Bike[Color] IN { "XX", "YY" } ) )
)

Mahesh0016_0-1682684360327.png

 


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

View solution in original post

1 REPLY 1
Mahesh0016
Super User
Super User

@Hemansi   FILTER(WinbackRawData,NOT (WinbackRawData[CallID]  IN{_Result1} ))
For E.g :
Price =
CALCULATE (
SUM ( Bike[Price] ),
FILTER ( Bike, NOT ( Bike[Color] IN { "XX", "YY" } ) )
)

Mahesh0016_0-1682684360327.png

 


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

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

Find out what's new and trending in the Fabric community.