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

Calculate Monthly Total between two dates

We recieve payment from customers on a reocurring basis for the duration of a contract.  I don't have a Date table associated to the fact table.  Is there a way to calculate monthly revenenue so it is viewable by Year, and Month?  We have a measure built and we can view by YearMonth but it isn't collapsible to just year.

 

Is it easiest to import the contract closed date and connect a date table to that column?

 

Below I posted a sample source table and a sample matrix output.

 

Table

Sales #NameContract ValueStart DateEnd DateRev Monthly Status
3046906Cust 1$164,1327/01/20206/30/2021$13,678Active
3062669Cust 2$4262628/01/20187/31/2020$7,104Active

 

Output Month and Year:

CustomerSales NumberProjectJun 20Jul 20Aug 20Sep 20Oct 20Nov 20etc
13046906x $13,678$13,678$13,678$13,678$13,678...
23062669x$7,104$7,104    ...

 

Output Year:

CustomerSales NumberProject201820192020etc
13046906x  $82,068...
23062669x$35,520$85,248$49,728...
1 ACCEPTED SOLUTION
dedelman_clng
Community Champion
Community Champion

Hi @Anonymous 

 

You do want a date table, but because you don't have a transaction table per se (you just show monthly revenue as a "component" of the contract), we can create a transaction table that can then get the output you seek.

 

1) Create the date table (CALENDARAUTO() works fine). Include at least Month and Year as columns.

 

2) Create a "transaction" table using CROSSJOIN (we will also put in the restrictions here of making sure the revenue entries are between the start and end date)

 

MonthlyRev =
FILTER (
    CROSSJOIN (
        FILTER ( DateTab, DAY ( DateTab[Date] ) = 1 ),
        SUMMARIZE (
            Contract,
            Contract[Sales #],
            Contract[Name],
            Contract[Rev Monthly ],
            Contract[Start Date],
            Contract[End Date]
        )
    ),
    [Date] >= [Start Date]
        && [Date] < [End Date]
)

 

3) Make the matrix with Year, Month as the columns, Name as the rows, Rev Monthly as the values

 

Yearly rollup:

2020-08-13 17_06_31-N_and_BASE_problem (3) - Power BI Desktop.png

Drill down to month:

2020-08-13 17_07_00-N_and_BASE_problem (3) - Power BI Desktop.png

Hope this helps

David

View solution in original post

3 REPLIES 3
dedelman_clng
Community Champion
Community Champion

Hi @Anonymous 

 

You do want a date table, but because you don't have a transaction table per se (you just show monthly revenue as a "component" of the contract), we can create a transaction table that can then get the output you seek.

 

1) Create the date table (CALENDARAUTO() works fine). Include at least Month and Year as columns.

 

2) Create a "transaction" table using CROSSJOIN (we will also put in the restrictions here of making sure the revenue entries are between the start and end date)

 

MonthlyRev =
FILTER (
    CROSSJOIN (
        FILTER ( DateTab, DAY ( DateTab[Date] ) = 1 ),
        SUMMARIZE (
            Contract,
            Contract[Sales #],
            Contract[Name],
            Contract[Rev Monthly ],
            Contract[Start Date],
            Contract[End Date]
        )
    ),
    [Date] >= [Start Date]
        && [Date] < [End Date]
)

 

3) Make the matrix with Year, Month as the columns, Name as the rows, Rev Monthly as the values

 

Yearly rollup:

2020-08-13 17_06_31-N_and_BASE_problem (3) - Power BI Desktop.png

Drill down to month:

2020-08-13 17_07_00-N_and_BASE_problem (3) - Power BI Desktop.png

Hope this helps

David

@Anonymous 

I was thinking on this one over night because I wanted to figure out a solution using a measure and was able to get there.  I know @dedelman_clng was able to solve it with a table but wanted to offer this as well so you could see it.

 

Monthly Rev Measure = 
    CALCULATE (
        SUMX ( VALUES ( Dates[Month Year] ),
            VAR _FirstDate = FIRSTDATE ( Dates[Date] )
            VAR _LastDate = LASTDATE ( Dates[Date] ) 
            RETURN
            CALCULATE (
                SUM( Contracts[Rev Monthly] ),
                Contracts[Start Date] <= _LastDate,
                Contracts[End Date] >= _FirstDate
            )
        )
    )

 

jdbuchanan71_0-1597415312972.png

 

Anonymous
Not applicable

@dedelman_clng This is exactly what I needed, thank you sir.  Worked like a charm. 

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