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

The ultimate Microsoft Fabric, Power BI, Azure AI & SQL learning event! Join us in Las Vegas from March 26-28, 2024. Use code MSCUST for a $100 discount. Register Now

Reply
michaelccdf
Helper I
Helper I

Year over Year comparison, Year to Date

I am trying to compare year over year data for enrollments for this school year and the last two school years.  The school calendar starts on July 1 and ends on June 30th.  I have a dates table where July is numbered 1, August 2, etc. 

 

My desired result is a table like the below:

Enrollments   
Program201620172018
Program 1535
Program 2245
Program 3344

 

where the enrollments shown for each year are the enrollments up to month of the max enrollment date in the enrollment table (i.e. the last enrollment captured).

 

I've tried a measure like this:

 

 [Enrollments To Date] =
VAR MaxDate = -- i would like this to be outside all filter contexts, i.e. to just find the month number for the max date in the Enrollments table.  this is not working.
    CALCULATE (
        MAX ( Dates[MonthNumber] ),
        FILTER (
            ALL ( Enrollments[StartDate] ),
            Enrollments[StartDate]
                = MAX ( Enrollments[StartDate] )
        )
    )
VAR EnrollmentsToDate =
    CALCULATE (
        COUNT ( Enrollments[StudentID] ),
        Dates[MonthNumber] <= MaxMonth
    ) 
RETURN
    EnrollmentsToDate

 

but this gives me the whole year's enrollments for each year rather than just the enrollments through October (the max month in the Enrollments table).

 

Last note is that there is a relationship between the StartDate column in the Enrollments table and the Date column in Dates.  Thanks a lot!

2 REPLIES 2
v-yuta-msft
Community Support
Community Support

Hi michaelccdf,

 

Could you please share the raw data and your origin table for further test? (Do mask the sensitive data in your table)

 

Regards,

Jimmy Tao

Thanks for the reply.  Enrollments and Dates tables are in different tabs here.  I would like to see the count of enrollments by program for each school year up to the max month number of the enrollments table.  For the sample data below, the last record in the Enrollments table is 10/1/2018, month number 4.  So the desired result would show the count of enrollments up to month number 4 for each school year. 

 

 

Helpful resources

Announcements
Fabric Community Conference

Microsoft Fabric Community Conference

Join us at our first-ever Microsoft Fabric Community Conference, March 26-28, 2024 in Las Vegas with 100+ sessions by community experts and Microsoft engineering.

February 2024 Update Carousel

Power BI Monthly Update - February 2024

Check out the February 2024 Power BI update to learn about new features.

Fabric Career Hub

Microsoft Fabric Career Hub

Explore career paths and learn resources in Fabric.

Fabric Partner Community

Microsoft Fabric Partner Community

Engage with the Fabric engineering team, hear of product updates, business opportunities, and resources in the Fabric Partner Community.