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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
Anonymous
Not applicable

Getting a running total of the number of rows after a given date but before another date?

So I have a table listing courses, with a "created_at" and an "expires_at" columns that have date values. I want to calculate the number of active courses for a long period, consisting of those courses that have been created but haven't been expired. I have a date table, simply called Dates and the Date column in Dates and the "created_at" column in courses are related. How do I calculate the number of courses offered on any given date?
This is what I wrote but it doesn't work. Returns a strange looking step graph for some reason.

Offered courses =
VAR Created = CALCULATE(
    COUNTA('courses course'[created_at]),
    FILTER(
        ALLSELECTED('Dates_early'[Date]),
        ISONORAFTER('Dates_early'[Date], MAX('Dates_early'[Date]), DESC)
    )
)

VAR Expired = CALCULATE(
    COUNTA('courses course'[expires_at]),
    FILTER(
        ALLSELECTED('Dates_early'[Date]),
        ISONORAFTER('Dates_early'[Date], MAX('Dates_early'[Date]), DESC)
    )
)
RETURN Created - Expired

Help?
1 REPLY 1
lbendlin
Super User
Super User

Please provide sanitized sample data that fully covers your issue. If you paste the data into a table in your post or use one of the file services it will be easier to work with. Please show the expected outcome.

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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