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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Anonymous
Not applicable

Count across two tables based on matching records and date condition

Hi,

 

I want to calculate conversion as following:

Table AA

deedeedudu_0-1658118475862.png

 

Table BB

deedeedudu_1-1658118498330.png

I want to count the matching records between the two tables with the condition that the latest date of table AA should be <= 15 days of the earliest date in table BB.

 

As per the above conditions the conversion count should be 1 as following

 

deedeedudu_0-1658118896815.png

 

 

 

3 REPLIES 3
amitchandak
Super User
Super User

@Anonymous , In case you need column you add column to table 2

 

maxx(filter(Table1, Table1[Date] <= Table2[Date] ), Table1[Date])

 

 

Count is

 

Count(filter(Table1, Table1[Date] <= Table2[Date] && Table1[Contract_id] = Table2[Contract_id]), Table1[Date])

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
Anonymous
Not applicable

Hi,

It is not giving the required output.

Anonymous
Not applicable

Hi @Anonymous,

You can try to use the following measure formula to calculate the row count based on your condition:

formula =
VAR currID =
    MAX ( TableA[ID] )
VAR _dateB =
    MAXX ( FILTER ( TableB, [ID] = currID ), [Date] )
RETURN
    COUNTROWS (
        FILTER (
            ALLSELECTED ( TableA ),
            [ID] = currID
                && [Date]
                    <= DATE ( YEAR ( _dateB ), MONTH ( _dateB ), DAY ( _dateB ) - 15 )
        )
    )

Regards,

Xiaoxin Sheng

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors