Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin 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.
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.
- 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:
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.
Solved! Go to Solution.
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
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.
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
68 | |
60 | |
51 | |
36 | |
35 |
User | Count |
---|---|
84 | |
71 | |
56 | |
45 | |
43 |