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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
Anonymous
Not applicable

Sumif between dates in two different tables

Hi Guys,

 

I need help summing the values of a second table if they are in the next 60 days of a date in the first table.

Its easiers ifi Show it:

 

Table 1:

SolicitingDate 

01/01/2019         

02/01/2019       

 

Table 2:

RedeemingDate ; TotalValue

02/01/2019     ;    10,000

02/02/2019     ;    15,000

 

What i want is to creat a measurement that can creat a column in the first table that is the sum of all TotalValue if the RedeemingDate is in the next 60 days. In the case aboe the Result would be:

 

 

Result

SolicitingDate ; Total Redemptions next 60D

01/01/2019     ;  25,000    

02/01/2019     ;  15,000

 

*All dates above are in teh following format "MM/DD/YYYY"

 

1 ACCEPTED SOLUTION

It probably has something to do with where you are pulling the date fields in from and the joins in your model.  When I test this measure and pull the date in from 'Solicitação Resgates' it works.

Total Redemptions next 60D = 
VAR StartingDate = MAX('Solicitação Resgates'[DataSolicitacao])
VAR EndingDate = StartingDate + 60
RETURN
    CALCULATE (
        SUM ( 'Cotizações Resgates'[Solicitação Resgates.Financeiro Ajustado] ),
        FILTER (
            'Cotizações Resgates',
            'Cotizações Resgates'[DataCotizacao] >= StartingDate
            && 'Cotizações Resgates'[DataCotizacao] <= EndingDate
        )
    )

crosssum.jpg

View solution in original post

4 REPLIES 4
jdbuchanan71
Super User
Super User

Hello @Anonymous 

Give this a try.

Total Redemptions next 60D =
VAR StartingDate = Table1[SolicitingDate]
VAR EndingDate = StartingDate + 60
RETURN
    CALCULATE (
        SUM ( Table2[TotalValue] ),
        FILTER (
            Table2,
            Table2[RedeemingDate] >= StartingDate
            && Table2[RedeemingDate] <= EndingDate
        )
    )
Anonymous
Not applicable

Hi @jdbuchanan71 ,

 

Thanks for the quick answer, the measurement works, with that i mean it does not return an error. Although it doesnt return anything.

 

I pasted the example with only two rows but i have a wide history of dates, what I need is for the measurement to be a rolling sum of all provisioned redemptions for the next 60 days for each soliciting date.

 

Here is what I used:

Measure =
   VAR
     StarDate=CALCULATE(MAX('Solicitação Resgates'[DataSolicitacao].[Date]))
   VAR
      EndDate=CALCULATE(MAX('Solicitação Resgates'[D+60]))
RETURN
  CALCULATE(
     SUM('Cotizações Resgates'[Solicitação Resgates.Financeiro Ajustado]);
     FILTER(
        'Cotizações Resgates';
        'Cotizações Resgates'[DataCotizacao]>=StarDate &&
        'Cotizações Resgates'[DataCotizacao]<=EndDate
         )
    )

I beleive hte problem is in setting the starting date and the ending date

It probably has something to do with where you are pulling the date fields in from and the joins in your model.  When I test this measure and pull the date in from 'Solicitação Resgates' it works.

Total Redemptions next 60D = 
VAR StartingDate = MAX('Solicitação Resgates'[DataSolicitacao])
VAR EndingDate = StartingDate + 60
RETURN
    CALCULATE (
        SUM ( 'Cotizações Resgates'[Solicitação Resgates.Financeiro Ajustado] ),
        FILTER (
            'Cotizações Resgates',
            'Cotizações Resgates'[DataCotizacao] >= StartingDate
            && 'Cotizações Resgates'[DataCotizacao] <= EndingDate
        )
    )

crosssum.jpg

Anonymous
Not applicable

@jdbuchanan71 

 

ITS ALIVE!! JK,

 

Thanks very much it worked, i was pulling a datetime value, i changed to date and it worked!!

 

You are a genious!

Helpful resources

Announcements
June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.