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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Count distinct months of distinct years

Hello World,

 

Could you help me?

 

I'm new in power BI and I didn't find the answer for my question on the internet

 

I Need to calculate a quantity of months have in my sheet.

 

For example, in 2019 I have five months (Aug, Sep, Oct, Nov and Dec), and in 2020 I have more five months (Jan, Feb, Mar, Apr, May) = Total of 10 months. When i make "distinctcount(Months)" the system count 12 months, but don't have Jun and Jul in my sheet.I want to know why that happens.

And in Aug of 2020, I don't know how count one new month.

 

Could you help with me these two questions?

Thankful

7 REPLIES 7
v-xuding-msft
Community Support
Community Support

Hi @Anonymous ,

 

You could try this firstly:

Count Months = CALCULATE(DISTINCTCOUNT('Table'[Month]),ALLEXCEPT('Table','Table'[Year]))

2.PNG 

 

Best Regards,
Xue Ding
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

Firsting, tnks so much for your help

 

unfortunately this formula keeps returning me 12 months, not 10

 

If you want to take a look at my database, the link is below

 

https://drive.google.com/drive/folders/1G1vJfbr-Nd-ZrkTm736q3Vy8G2oJeu9U?usp=sharing

 

@Anonymous 

maybe you can try add a month column

month=month(table[date])

Then distinctcount(month)





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




ryan_mayu
Super User
Super User

@Anonymous 

Please share the sample data and the expected output.





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Anonymous
Not applicable

Hi Ryan,

 

Follow Bellow link of the sheet

 

https://drive.google.com/drive/folders/1G1vJfbr-Nd-ZrkTm736q3Vy8G2oJeu9U?usp=sharing

 

I need that the count of the months returns 10

the way I'm doing it is returning 12, and in my database there are no months June and July

 

GuiManfredo_0-1593609845132.png

so far I am using the same formula as in the comment below:

Count Months = CALCULATE(DISTINCTCOUNT('Abonos'[Date].[Month]),ALLEXCEPT('Abonos',Abonos[Date].[Month]))

 

I don't have a DCalendar sheet, so it doesn't make sense to make a formula using another sheet

 

Tnks for your Help

You could add a calculated column to your table with this formula

 

YearMonth = FORMAT(Table[Date], "YYYMMM")

 

and then make a measure that does a DISTINCTCOUNT of that column.

 

If this works for you, please mark it as the solution.  Kudos are appreciated too.  Please let me know if not.

Regards,

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


nvprasad
Solution Sage
Solution Sage

Hi,

I believe you are applying distinct count on the column which have 10 months instead of calendar table (if you have any).

 

Appreciate a Kudos! 🙂
If this helps and resolves the issue, please mark it as a Solution! 🙂

Regards,
N V Durga Prasad

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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