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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

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
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

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