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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

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:

c.jpg

 

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:

 

Capture.JPG

 

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

1 ACCEPTED SOLUTION

Hi,

You are welcome.  You may download my PBI file from here.

Hope this helps.

Untitled.png


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

View solution in original post

17 REPLIES 17

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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