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 of Months Measure in Power BI YTD.

Hello everyone,

 

Hope you are well,

 

I would like to make a measure that returns my "Date, Period" to   Count of Months up to that month.

 

For example if I  select March 2020  =  the Measure should show : 3    (Jan Feb March) counts.

 

If i choose my date filter April 2019 = the Measure should show : 4    (Jan Feb March) counts.

 

Can you please help with this?

 

Thank you,

 

Regards,

 

Ahmet

 

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@Anonymous , If April is coming from a date table

then

month(maxx(allselected(Date),Date[Date]))

 

or you can use a distinct count of the month

YTD Sales = CALCULATE(distinctcount(Table[Month]),DATESYTD('Date'[Date],"12/31"))

 

for that also prefer to have the calendar

To get the best of the time intelligence function. Make sure you have a date calendar and it has been marked as the date in model view. Also, join it with the date column of your fact/s. Refer :
https://radacad.com/creating-calendar-table-in-power-bi-using-dax-functions
https://www.archerpoint.com/blog/Posts/creating-date-table-power-bi
https://www.sqlbi.com/articles/creating-a-simple-date-table-in-dax/

See if my webinar on Time Intelligence can help: https://community.powerbi.com/t5/Webinars-and-Video-Gallery/PowerBI-Time-Intelligence-Calendar-WTD-YTD-LYTD-Week-Over-Week/m-p/1051626#M184


Appreciate your Kudos.

View solution in original post

3 REPLIES 3
v-xicai
Community Support
Community Support

Hi @Anonymous ,

 

You may create measure like DAX below.

 

Measure1= CALCULATE(MONTH(MAX(Table1[Date])), ALLSELECTED(Table1))

 

Best Regards,

Amy 

 

Community Support Team _ Amy

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

amitchandak
Super User
Super User

@Anonymous , If April is coming from a date table

then

month(maxx(allselected(Date),Date[Date]))

 

or you can use a distinct count of the month

YTD Sales = CALCULATE(distinctcount(Table[Month]),DATESYTD('Date'[Date],"12/31"))

 

for that also prefer to have the calendar

To get the best of the time intelligence function. Make sure you have a date calendar and it has been marked as the date in model view. Also, join it with the date column of your fact/s. Refer :
https://radacad.com/creating-calendar-table-in-power-bi-using-dax-functions
https://www.archerpoint.com/blog/Posts/creating-date-table-power-bi
https://www.sqlbi.com/articles/creating-a-simple-date-table-in-dax/

See if my webinar on Time Intelligence can help: https://community.powerbi.com/t5/Webinars-and-Video-Gallery/PowerBI-Time-Intelligence-Calendar-WTD-YTD-LYTD-Week-Over-Week/m-p/1051626#M184


Appreciate your Kudos.

tex628
Community Champion
Community Champion

I believe this should work:

Measure = MONTH( MAX(Calendar[Date]))


Br,
J


Connect on LinkedIn

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.