Forum Discussion
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
- johnt75
Super User
Try
_callLength = VAR SalesRepNumbers = VALUES ( SalesReps[Phone] ) VAR Result = CALCULATE ( SUMX ( PhoneLogs, PhoneLogs[CallLength] ), NOT PhoneLogs[RecipientNo] IN SalesRepNumbers ) RETURN Result - Fistachpl
Helper III
Does not work 😞
- techies
Super 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 thisTotalLength NonSalesReps =CALCULATE (SUM ( PhoneLogs[Length]),PhoneLogs[IsRecipientSalesRep] = "No")TotalLength SalesReps =CALCULATE (SUM ( PhoneLogs[Length] ),PhoneLogs[IsRecipientSalesRep] = "Yes")- Fistachpl
Helper 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()