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! Learn more

Reply
jcastr02
Post Prodigy
Post Prodigy

Calculation between two tables using max date

I have two tables below.  I am trying to create a calculated column BY STORE for the previous 43 days.  However, typically Table 2 is always one day behind so I'd like for it to go back 43 days of whenever both tables have the same max date.  In this case, we would go back 43 days from 1/2/2025, since 1/3/2025 hasn't loaded in table 2.  

Then based off those dates 

Do Calculation:     
Sum of Shipped   / (Sum of Shipped+ Sum of Product Reviewed)

Then group by store so that end values are one column for the store and one value for the calculation above.

Example below

Table 1 Table 2
DateStore#Shipped DateStore#Product Reviewed
1/1/202534525 1/1/20253456
1/1/202589910 1/1/20258995
1/1/20256632 1/1/20256634
1/2/202534566 1/2/20253455
1/2/202589922 1/2/20258993
1/2/202566311 1/2/20256631
1/3/202534511    
1/3/202589912    
1/3/20256635    
1 ACCEPTED SOLUTION
lbendlin
Super User
Super User

4 REPLIES 4
v-karpurapud
Community Support
Community Support

Hi @jcastr02 

I wanted to check if you had the opportunity to review the information provided. Please feel free to contact us if you have any further questions. If my response has addressed your query, please accept it as a solution and give a 'Kudos' so other members can easily find it.

Thank you.

v-karpurapud
Community Support
Community Support

Hi @jcastr02 

Could you please confirm if your query have been resolved the solution provided by @lbendlin and @DataNinja777 ? If they have, kindly mark the helpful response and accept it as the solution. This will assist other community members in resolving similar issues more efficiently.

Thank you

DataNinja777
Super User
Super User

Hi @jcastr02 ,

 

To achieve the desired result, first create a DateTable that spans the full range of dates in your data using the following DAX:

DateTable = CALENDAR(MIN('Table1'[Date]), MAX('Table1'[Date]))

Next, define a measure to determine the latest common date between both tables, since Table2 often lags behind by a day. This ensures that the 43-day window only includes dates that exist in both tables:

MaxCommonDate = 
CALCULATE (
    MAX ( 'Table1'[Date] ),
    INTERSECT (
        SELECTCOLUMNS ( 'Table1', "Date", 'Table1'[Date] ),
        SELECTCOLUMNS ( 'Table2', "Date", 'Table2'[Date] )
    )
)

Now you can create the main measure that filters both tables to only include data from the last 43 days up to the max common date. It then calculates the sum of shipped and product reviewed values by store and returns the ratio of shipped to the total of shipped plus reviewed:

Shipped_vs_Reviewed = 
VAR MaxDate = [MaxCommonDate]
VAR StartDate = MaxDate - 42
VAR FilteredShipped =
    FILTER (
        ALL ( 'Table1' ),
        'Table1'[Date] >= StartDate && 'Table1'[Date] <= MaxDate
    )
VAR FilteredReviewed =
    FILTER (
        ALL ( 'Table2' ),
        'Table2'[Date] >= StartDate && 'Table2'[Date] <= MaxDate
    )
VAR ShippedByStore =
    CALCULATE (
        SUM ( 'Table1'[Shipped] ),
        FilteredShipped
    )
VAR ReviewedByStore =
    CALCULATE (
        SUM ( 'Table2'[Product Reviewed] ),
        FilteredReviewed
    )
RETURN
    DIVIDE (
        ShippedByStore,
        ShippedByStore + ReviewedByStore
    )

This measure can then be added to a table or matrix visual with Store# on rows to display the result for each store.

 

Best regards,

lbendlin
Super User
Super User

lbendlin_0-1745595112442.png

 

 

Helpful resources

Announcements
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!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

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