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

Microsoft is giving away 50,000 FREE Microsoft Certification exam vouchers. Get Fabric certified for FREE! Learn more

Reply
Anonymous
Not applicable

YTD Weekly and Monthly not working

Hello everyone,

 

I'm having a problem with my "This month's" and "This week's" static numbers. I am trying to display one specific number that will be the same every week for a month. You could call it a "Goal". I have a week rank and month rank column in my calendar table, however, when I put the DAX I am using in a visual it is showing last month's number. For example, I want to show a headcount for this week/month, which usually doesn't change over a week or month, but it shows last month's number and if I use a slicer to filter to next month it shows what should be this months number. Any help on this would be greatly appreciated!

 

This is the DAX I've been currently using. When I use month rank it produces (blank)

 

This Month's Headcount = CALCULATE(sum('Monthly Information'[Headcount]), FILTER(ALL('Calendar'),'Calendar'[Week Rank]=max('Calendar'[Week Rank])))
1 ACCEPTED SOLUTION
Anonymous
Not applicable

So, I figured out why it didn't work. In my calendar M code, I had this as my end date: EndDate = Date.EndOfDay(Today), when it should have been EndDate = Date.EndOfMonth(Today). If you have end of date today the "Month Rank" does not work properly. Also, if you don't want the future months showing up on visuals, I suggest in the M code to use Date.EndOfMonth. EndOfYear will populate all months in your visuals.👍

View solution in original post

3 REPLIES 3
amitchandak
Super User
Super User

@Anonymous , for month you can use datesmtd or month rank on month year

 

This Month's Headcount = CALCULATE(sum('Monthly Information'[Headcount]), FILTER(ALL('Calendar'),'Calendar'[Month Rank]=max('Calendar'[Month Rank])))

 

examples

MTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD('Date'[Date]))
last MTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD(dateadd('Date'[Date],-1,MONTH)))
last month Sales = CALCULATE(SUM(Sales[Sales Amount]),previousmonth('Date'[Date]))
MTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD('Date'[Date]))
last MTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD(dateadd('Date'[Date],-1,MONTH)))

 

 

new column

Month Rank = RANKX(all('Date'),'Date'[Month Start date],,ASC,Dense) //Yea month column /YYYYMM

 

This Month = CALCULATE(sum('Table'[Qty]), FILTER(ALL('Date'),'Date'[Month Rank]=max('Date'[Month Rank])))
Last Month = CALCULATE(sum('Table'[Qty]), FILTER(ALL('Date'),'Date'[Month Rank]=max('Date'[Month Rank])-1))

 

Power BI — Month on Month with or Without Time Intelligence
https://medium.com/@amitchandak.1978/power-bi-mtd-questions-time-intelligence-3-5-64b0b4a4090e
https://www.youtube.com/watch?v=6LUBbvcxtKA

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

Both of these do not work. Any idea why?

Anonymous
Not applicable

So, I figured out why it didn't work. In my calendar M code, I had this as my end date: EndDate = Date.EndOfDay(Today), when it should have been EndDate = Date.EndOfMonth(Today). If you have end of date today the "Month Rank" does not work properly. Also, if you don't want the future months showing up on visuals, I suggest in the M code to use Date.EndOfMonth. EndOfYear will populate all months in your visuals.👍

Helpful resources

Announcements
Notebook Gallery Carousel1

NEW! Community Notebooks Gallery

Explore and share Fabric Notebooks to boost Power BI insights in the new community notebooks gallery.

April2025 Carousel

Fabric Community Update - April 2025

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

Top Solution Authors