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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
cb2222
Regular Visitor

Calculating a Historical Sum Table

Hi,


I have a table that contains a column for date created and date completed of each record. I am looking to create a new table to track the number of open records for each day of the year, so that I can display the historical trends of open records.


I've created a new table using the Calendar function, but I am having trouble creating a second column to sum the number of open records for each day. When I try to use the calculate function, I get an error anytime I try to use the date field created with the calendar function.


The two criteria that I am trying to use is the date created must be after the date row of the new table, and the date row needs to be before the date completed.

1 ACCEPTED SOLUTION
SamWiseOwl
Super User
Super User

Hi @cb2222 

Have you joined the tables together or are the seperate?
I've encountered the error before when you are using the built in Calendar table vs the CalendarAuto function.

 

SamWiseOwl_0-1731452755822.png

 
Sales open on day =
var currDate = [Date] --Current row in this table
RETURN
CALCULATE(
    sum(Sales[Quantity])--Calculation you want to perform
    ,Sales[SaleDate] <= currDate --Sales open before this date
    && Sales[PaymentDate] >= currDate --sales closed after this date
) --use && to do AND tests and || for OR tests

If you are happy with this answer please mark as a solution for others to find !

Kudos are always appreciated! Check out our free Power BI video courses.

View solution in original post

1 REPLY 1
SamWiseOwl
Super User
Super User

Hi @cb2222 

Have you joined the tables together or are the seperate?
I've encountered the error before when you are using the built in Calendar table vs the CalendarAuto function.

 

SamWiseOwl_0-1731452755822.png

 
Sales open on day =
var currDate = [Date] --Current row in this table
RETURN
CALCULATE(
    sum(Sales[Quantity])--Calculation you want to perform
    ,Sales[SaleDate] <= currDate --Sales open before this date
    && Sales[PaymentDate] >= currDate --sales closed after this date
) --use && to do AND tests and || for OR tests

If you are happy with this answer please mark as a solution for others to find !

Kudos are always appreciated! Check out our free Power BI video courses.

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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