Forum Discussion
USERELATIONSHIP, FILTER, CALCULATE, COUNT
Hi all,
I have 3 tables
'CALENDAR LOOKUP'[Date] to OPPORTUNITY_INFO[CREATED_DATE] -> active relationship
I have a slicer that's using 'CALENDAR LOOKUP'[Date]
I am trying to get the COUNT of the OPPORTUNITY_ID with the below crietera:
- SUBMITTED_DATE in the last 30 days
- OPPORTUNITY_INFO[CONVERTED_FROM_LEAD] = "Yes"
- CAMPAIGN_LOOKUP[CAMPAIGN_TYPE] IN {"Email", "Lead Generation", "Paid Search", "Seminar / Conference", "Website"}
Below is the DAX code that I have at the moment, it's not giving me the correct result. (now it's giving me 141, but it should be more than 200). I am not sure how to correctly use USERELATIONSHIP + FILTER(), could anyone please let me know where I did wrong in my DAX code?
test =
CALCULATE(
DISTINCTCOUNT(OPPORTUNITY_INFO[OPPORTUNITY_ID]),
USERELATIONSHIP(OPPORTUNITY_INFO[SUBMITTED_DATE], 'CALENDAR LOOKUP'[Date]),
FILTER(
OPPORTUNITY_INFO,
OPPORTUNITY_INFO[CONVERTED_FROM_LEAD] = "Yes" &&
RELATED(CAMPAIGN_LOOKUP[CAMPAIGN_TYPE]) IN {"Email", "Lead Generation", "Paid Search", "Seminar / Conference", "Website"}
)
)
I'm pretty sure the issue is that USERELATIONSHIP is not being applied to OPPORTUNITY_INFO inside the FILTER. There are ways to fix that but I think you might be able to bypass that problem entirely by changing your filter conditions.
Try this:
CALCULATE ( DISTINCTCOUNT ( OPPORTUNITY_INFO[OPPORTUNITY_ID] ), OPPORTUNITY_INFO[CONVERTED_FROM_LEAD] = "Yes", CAMPAIGN_LOOKUP[CAMPAIGN_TYPE] IN { "Email", "Lead Generation", "Paid Search", "Seminar / Conference", "Website" }, USERELATIONSHIP ( OPPORTUNITY_INFO[SUBMITTED_DATE], 'CALENDAR LOOKUP'[Date] ) )
2 Replies
- AlexisOlsonSuper User
I'm pretty sure the issue is that USERELATIONSHIP is not being applied to OPPORTUNITY_INFO inside the FILTER. There are ways to fix that but I think you might be able to bypass that problem entirely by changing your filter conditions.
Try this:
CALCULATE ( DISTINCTCOUNT ( OPPORTUNITY_INFO[OPPORTUNITY_ID] ), OPPORTUNITY_INFO[CONVERTED_FROM_LEAD] = "Yes", CAMPAIGN_LOOKUP[CAMPAIGN_TYPE] IN { "Email", "Lead Generation", "Paid Search", "Seminar / Conference", "Website" }, USERELATIONSHIP ( OPPORTUNITY_INFO[SUBMITTED_DATE], 'CALENDAR LOOKUP'[Date] ) )- AnonymousNot applicable
This works! Thank you so much AlexisOlson