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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

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
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

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.