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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
mhsieh
Helper II
Helper II

USERELATIONSHIP, FILTER, CALCULATE, COUNT

Hi all,

I have 3 tables

'CALENDAR LOOKUP'[Date]   to   OPPORTUNITY_INFO[SUBMITTED_DATE]    -> inactive relationship
'CALENDAR LOOKUP'[Date]   to   OPPORTUNITY_INFO[CREATED_DATE]        -> active relationship

mhsieh_0-1664905089424.png

 

I have a slicer that's using 'CALENDAR LOOKUP'[Date]

mhsieh_2-1664904904524.png

 

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"}
    )
)

 

 

 

 

 

 

 

 

1 ACCEPTED SOLUTION
AlexisOlson
Super User
Super 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] )
)

View solution in original post

2 REPLIES 2
AlexisOlson
Super User
Super 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] )
)

This works! Thank you so much @AlexisOlson

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel

Power BI Monthly Update - May 2024

Check out the May 2024 Power BI update to learn about new features.

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.