Forum Discussion

Fistachpl's avatar
Fistachpl
Icon for Helper III rankHelper III
1 year ago
Solved

NOT INVALUES is not working

I have two tables:

SalesReps with Columns Name, Phone
Jan Kowalski, 48123456789

and PhoneLogs with Columns
Caller, RecipientNo, CallLength and some other columns

I have relation between both tables: *:1 PhoneLogs[Caller] to SalesReps[Name]

Now I want to calculate the length of all calls that were not made to other Sales representatives (RecipientNo does not exist in SalesReps[Phone] and display it in table visual (not exact formatting but You will get an idea):

_callLenght = 
calculate(
sumx(PhoneLogs, PhoneLogs[CallLength]),
FILTER(
PhoneLogs,
NOT PhoneLogs[RecipientNo] IN VALUES(SalesReps[Phone])
)
)



But this measure still calculates sum of length of all calls...

Where is an error in my way of thinking?

Thanks in advance!

  • Hi Fistachpl ,

    Thank you for reaching out to Microsoft Fabric Community Forum.

     

    here can calculate how many times each Sales Rep called another Sales Rep based on phone number here i have used TREATAS & LOOKUPVALUE function.

    CallsToSalesReps :=
    CALCULATE(
    COUNTROWS(PhoneCalls),
    TREATAS(VALUES(SalesRep[Phone]), PhoneCalls[RecipientNumber])
    )

    2)

    SalesRepName =
    LOOKUPVALUE(
    SalesRep[Name],
    SalesRep[Phone], PhoneCalls[RecipientNumber]
    )

     

    Regards,

    Chaithanya.

17 Replies

  • Try

    _callLength =
    VAR SalesRepNumbers =
        VALUES ( SalesReps[Phone] )
    VAR Result =
        CALCULATE (
            SUMX ( PhoneLogs, PhoneLogs[CallLength] ),
            NOT PhoneLogs[RecipientNo] IN SalesRepNumbers
        )
    RETURN
        Result
    
    • Fistachpl's avatar
      Fistachpl
      Icon for Helper III rankHelper III

      It does not work, but I am not suprised as it is basically the same syntax I tried 😕

       

       

      • johnt75's avatar
        johnt75
        Icon for Super User rankSuper User

        What columns from which tables do you have in the table visual ?

  • Hi Fistachpl please try this measure

     

    measure=
    CALCULATE (
        SUM ( 'phone length'[CallLength] ),
        FILTER (
            'phone length',
            NOT CONTAINS (
                SalesReps,
                SalesReps[Phone],
                'phone length'[RecipientNo]
            )
        )
    )
    • techies's avatar
      techies
      Icon for Super User rankSuper User

      Hi Fistachpl based on the pbix file shared , you can create a calculated column first to check the sales rep's yes/no

       

      IsRecipientSalesRep =
      IF (
          ISBLANK (
              LOOKUPVALUE (
                  SalesReps[Name],          
                  SalesReps[Phone],          
                  PhoneLogs[Recipient]      
              )
          ),
          "No",
          "Yes"
      )
       
      and then measures as this
       
      TotalLength NonSalesReps =
      CALCULATE (
          SUM ( PhoneLogs[Length]),
          PhoneLogs[IsRecipientSalesRep] = "No"
      )
       
      TotalLength SalesReps =
      CALCULATE (
          SUM ( PhoneLogs[Length] ),
          PhoneLogs[IsRecipientSalesRep] = "Yes"
      )
      • Fistachpl's avatar
        Fistachpl
        Icon for Helper III rankHelper III

        Yes this I know but I did not use the Yes/No but merged two queries and have the name of the recipient (if he is the sales representative). This way I can calculate how many times, each of the Sales Rep called other sales reps - just gives more options. My question here was more to check why it does not calculate using IN VALUES()