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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
DanielReinman
Frequent Visitor

Count of Months with Data

I have a need to dynamically calculate the number of months for which data exists, using a measure.

In its simplest form, I have a Calendar Table, Physician Table, and an Appointment Table. 

Depending on the dates selected or visible in a visual, I need the measure to be able to tell me how many months have data. 

i.e

To illustrate, If the data was put into a matrix, like the one below, and slices limited the page to just Jan-March, the measure would be able to tell me that Physician A has 2 months with data, Physician B has 3 months of data, etc. 

 

DanielReinman_0-1693945411468.png

- but if I were to adjust the slicers to show more months, the measure results would change accordingly, such as below, the measure would now calculate 4 months of data for Physician A:

DanielReinman_1-1693946017895.png

 

Icing on the cake would be to add a condition, such as Physician D has X number of months with data where CPT Code = Y.

1 ACCEPTED SOLUTION
MURTAZA
Resolver I
Resolver I

The simplest solution might be just to do a DISTINCTCOUNT of months. I am guessing your appointment table has the dates. Just use that date to extract month and do a distinctcount on the months

View solution in original post

3 REPLIES 3
MURTAZA
Resolver I
Resolver I

The simplest solution might be just to do a DISTINCTCOUNT of months. I am guessing your appointment table has the dates. Just use that date to extract month and do a distinctcount on the months

Wow - yeah, I was really overthinking this. Works like a charm!

On second thought, you may wanna do DISTINCTCOUNT on MONTH-YEAR (03-2023), because if you analyze the data over multiple years, DISTINCTCOUNT on just Month wouldn't work. 

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Prices go up Feb. 11th.

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

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