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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

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
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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