Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
7 years ago
Solved

Rolling Inner Join Sum

Hey Guys, 

 

I'm looking to do an inner join on a uniqueID from one table to another and then take the sum of a dollar amount  from the other table.  I want to write this as a DAX measure.

 

So I have 4 Tables right now like this:

 

What I want to do is a running inner join on the "ID" on TableA and TableB and sum the "Spent" on TableB , where the running total is 3 months ahead (eg. Jan 2018 sum would be Jan 2018, Feb 2018, Mar 2018, and Apr 2018).  So if I plot a a table it would look like this:

 

 

I already have a function to do a normal rolling sum, like this:

Roll3Sum =
CALCULATE (
    SUM ( TableB[Spent] ),
    FILTER (
        ALL ( 'Date' ),
        'Date'[Rank] >= MAX ( 'Date'[Rank] )
            && 'Date'[Rank]
                <= MAX ( 'Date'[Rank] ) + 3
    )
)

I wanto to perform this but inner join on ID's on the specified month and roll it 3 months ahead like mentioned above.

 

*EDIT*

here is some sample data, you will see that in the FinalOutput tab, the TotalSpent column is an inner join on the ID'S from tab A and tab B with a 4 month roll including the selected month and the sum of the Spent column from tab B.

 

Here is the dropbox link:

https://www.dropbox.com/s/mvjzeodkvv5flwi/TestExample.xlsx?dl=0

17 Replies

  • Hi,

    Share TableA and TableB data (in a format that can be pasted in MS Excel) and show the expected result.

    • Anonymous's avatar
      Anonymous
      Not applicable

      Ashish_Mathur Hey, I uploaded the sample data onto my original post under *EDIT*.  Thank you!

      • Ashish_Mathur's avatar
        Ashish_Mathur
        Super User

        Hi,

        In the FinalOutput worksheet, i understand how you got the figures in column C.  How did you arrive at the numbers in column D?  Show the Excel formula in those cells.