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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

Distinct Count by Year

Hello,

 

I believe I just need a relatively easy fix, but I'm struggling to get there. Hoping somebody can help. 

 

I am able to find the distinct number of months of a given plan year (not calendar year), using the DistinctCount function; however, when I drill down from Plan Year to Month, the Distinctcount is now just 1 instead of keeping the distinctcount where it was before. I understand why this is happening but not sure how to correct it so that the distinct count of dates remains constant when drilling down. 

Right now my formula reads as: 

CALCULATE(DISTINCTCOUNT('Calendar'[Date]),'Calendar'[Plan Year Ending]). 
 
Any help would be much appreciated. Thank you!
5 REPLIES 5
DataZoe
Microsoft Employee
Microsoft Employee

@Anonymous I think you are trying to show the # months in your year even when you are just looking at one month?  If so, this may work for you!

 

 

Count Months in Year = if(ISINSCOPE('calendar'[Month]),
CALCULATE(DISTINCTCOUNT('calendar'[Month]),'calendar'[Month]),
DISTINCTCOUNT('calendar'[Month]))

 

Respectfully,
Zoe Douglas (DataZoe)



Follow me on LinkedIn at https://www.linkedin.com/in/zoedouglas-data
See my reports and blog at https://www.datazoepowerbi.com/

Greg_Deckler
Community Champion
Community Champion

Perhaps:

COUNTROWS(
DISTINCT(
SELECTCOLUMNS(
FILTER(ALL('Calendar'),'Calendar'[Plan Year Ending'] = MAX('Calendar'[Plan Year Ending]),
"__Date",'Calendar'[Date]
)
)


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...
Anonymous
Not applicable

Hi @Greg_Deckler, I think you are close, but the visualization now is showing the count of all rows, not just those in the current plan year. If you see the visual below, the tall line should be at 6 for January through June (short plan year) and it should be 12 for July through the following June. Instead it is showing all 18 months. Any suggestions? Thanks!

 

 
Anonymous
Not applicable

@Greg_Deckler  Ok so I found out the issue. There are 18 distinct months becuase there are 2 different plan years and they overlap by 6 months. So I also need to filter not only by plan year but also by the account. I'm still working on figuring out how to do so, but that is the last part here. Thanks!

I'm just pure guessing on this stuff @Anonymous because no sample data and expected output to go off of. Please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490

 

I could make a suggestion with the formula because it only referenced one table but I have no clue where your account column is coming from or how it is related or what columns are in the visual, etc.

 



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.