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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Anonymous
Not applicable

Measure for calculating appointments

I have the following measure for which counts the number of appointments for a given day:

CALCULATE(COUNT(Appointment[Date appointment]),
FILTER(Appointment, Appointment[Status] = "Planned" || Appointment[Status] = "Occurred"))

 

This produces the following table when combined with a Calendar[Date] column:

Sohan_0-1658745462145.png

 

I want another column which shows the sum of appointments for the coming 6 months, for example, the 4-1-2021, which would sum the values from 4-1-2021 til 3-7-2021. However, the Appointment[Booking date] should not be larger than in this case 4-1-2021.

 

Does anyone know how to achieve this?

 

10 REPLIES 10
amitchandak
Super User
Super User

@Anonymous , Assume active join of date table is with Appoint date

 

Rolling 6 = CALCULATE(Calculate(Countrows(Table), filter(Table, Table[Booking Date] <=Max('Date'[Date]))) ,DATESINPERIOD('Date'[Date ],MAX('Date'[Date ]),6,MONTH))

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

This unfortunately does not seem to provide the desired result:

 

Sohan_0-1658747634139.png

 

Anonymous
Not applicable

Hi @Anonymous ,

 

Please try:

TEST =
CALCULATE (
    COUNT ( Appointment[Date appointment] ),
    FILTER (
        Appointment,
        Appointment[Status] = "Planned"
            || Appointment[Status] = "Occurred"
    )
)
Rolling 6 = 
CALCULATE (
    CALCULATE (
        [TEST],
        FILTER ( 'Calendar', 'Calendar'[Date] <= MAX ( 'Calendar'[Date] ) )
    ),
    DATESINPERIOD ( 'Calendar'[Date], MAX ( 'Calendar'[Date] ), 6, MONTH )
)

 

Best Regards,
Gao

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly -- How to provide sample data

Anonymous
Not applicable

Thank you for your respone @Anonymous! 

 

The Appointment[Booking date] should not be larger than the date that is displayed in the 'Date' column as shown below. Right now, this constraint is not in place, hence why the values in 'Rolling 6.2' are too large. Do you have any idea how to achieve this?

 

Sohan_0-1659345699331.png

 

Anonymous
Not applicable

Hi @Anonymous ,

 

Please try:

Rolling 6 = 
CALCULATE (
    CALCULATE (
        [TEST],
        FILTER ( 'Appointment', 'Appointment'[Booking date] <= MAX ( 'Calendar'[Date] ) )
    ),
    DATESINPERIOD ( 'Calendar'[Date], MAX ( 'Calendar'[Date] ), 6, MONTH )
)

Best Regards,
Gao

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly -- How to provide sample data

Anonymous
Not applicable

@Anonymous I get the same result with this measure. The value for January 4th, for example, should be '942'. The booking date should not be larger than the 'row date' that is displayed in the table (which comes from Calendar[Date]). Any ideas?

Anonymous
Not applicable

Hi @Anonymous ,

 

I would first consider the relationship, can 'Appointment'[Booking date] be filtered by 'Calendar'[Date]?

 

Would you mind providing some sample files that do not contain sensitive data? It would be helpful to find out why, thanks in advance!

How to provide sample data in the Power BI Forum

 

Best Regards,
Gao

Community Support Team

Anonymous
Not applicable

@Anonymous Please find a sample file here: PBI sample file

Anonymous
Not applicable

Hi @Anonymous ,

 

The formula output is correct. Does your expected output need to consider de-duplicating the count of the results? This may be the reason for the larger result. Please check this file. The latter output is the result of considering the de-duplication.

vcgaomsft_0-1659492707426.png

If I misunderstood your needs, you could pick a date and demonstrate the calculation process and output based on this file, thanks in advance!

 

Best Regards,
Gao

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly -- How to provide sample data

Anonymous
Not applicable

Dear @Anonymous Thank you for your help! In the same PBI file, I have added a page (page 2) with manual filters which provides an example of the result I am looking for. I have also added some comments to try and clarify things further. Does this maybe clarify things? PBI file 

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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.

Top Solution Authors