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

Try your skills in the Power BI Dataviz World Championship! Round one ends June 26. Join now

Reply
apmulhearn
Helper III
Helper III

Distinct Count of Data Based on Contact ID Relationship and Date Criteria - 2 tables

Hello,

 

I have  Table1 with Email Event Type Activity, Dates and Contact IDs.

I have Table 2 with ContactID and Reservation Date.

I want to know how many DIFFERENT Email Names a contact CLICKED (Action) BEFORE Their Book Date in Table2.

Thank you for any help.

 

 

apmulhearn_1-1668730829797.png

ContactIDEmail DateEmail NameActionBookDateContactIDResultDistinct Count of Email Name Clicks BEFORE Book Date in Table 2

Table 1    Table 2  Desired Measure Results   
     
1234561/1/2020ZebraClick 6/1/2021123456 1234563   
1234565/1/2020ZebraOpen 7/1/2021789654 7896541   
1234561/1/2021CheetahOpen         
1234561/15/2021ElephantOpen         
1234562/1/2021ZebraClick         
1234562/6/2021PantherClick         
1234562/9/2021PantherClick         
1234563/1/2021CheetahClick         
1234563/5/2021ZebraClick         
1234561/1/2022PantherClick         
1234568/1/2022ZebraClick         
1234569/1/2022CheetahClick         
7896542/1/2020LionClick         
7896542/1/2020LionOpen         
7896542/2/2021LionClick         
7896542/2/2022ZebraClick         
             
             
1 ACCEPTED SOLUTION
v-yalanwu-msft
Community Support
Community Support

Hi, @apmulhearn ;

You could check the relationship about two tables:

vyalanwumsft_0-1669014395165.png

Then create a measure.

count = 
CALCULATE(DISTINCTCOUNT('Table1'[Name]),FILTER('Table1',[Action]="Click"&&[Date]>=MAX('Table2'[BookDate])))

The final show:

vyalanwumsft_1-1669014500584.png


Best Regards,
Community Support Team _ Yalan Wu
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

2 REPLIES 2
v-yalanwu-msft
Community Support
Community Support

Hi, @apmulhearn ;

You could check the relationship about two tables:

vyalanwumsft_0-1669014395165.png

Then create a measure.

count = 
CALCULATE(DISTINCTCOUNT('Table1'[Name]),FILTER('Table1',[Action]="Click"&&[Date]>=MAX('Table2'[BookDate])))

The final show:

vyalanwumsft_1-1669014500584.png


Best Regards,
Community Support Team _ Yalan Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

amitchandak
Super User
Super User

@apmulhearn , You can join them in Power bi and then can get

 

distinctcount(Table1[Email]) and plot with contact id or date from table 2

 

or you https://docs.microsoft.com/en-us/dax/treatas-function

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
Fabric Data Days is here Carousel

Fabric Data Days 2026

Don't miss out on Data Days, June 15 through August 7. Learn Fabric, Power BI, SQL, AI and more.

May Power BI Update Carousel

Power BI Monthly Update - May 2026

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

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.