cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anonymous
Not applicable

TOTALMTD and PREVOUSMONTH

Hi , I have a data set where I have 100 row for the month July 2020 and 0 rows for Aug 2020.

 

I wrote DAX using TOTALMTD thinking it would show 0 as dont have any rows for Aug 2020 but it is showing 100. 

ThisMonthUserActivity =
VAR ThisMonth = TOTALMTD( Count ( 'Logs'[.id] ),(Logs[CreationDate]))
Return
COALESCE(ThisMonth,0)

 

I also wrote PreviousMonth measure and it is showing me 0

PrevMonthUserActivity =
VAR PrevMonth = CALCULATE( Count ( 'Logs'[id] ),PREVIOUSMONTH(Logs[CreationDate]))
Return
COALESCE(PrevMonth,0)
 
Why TotalMTD is taking last months data into context? And why PrevousMonth is giving me 0 while I have 100 rows of July 2020. 
 
Thanks for your help.
 
2 REPLIES 2
Greg_Deckler
Super User
Super User

@dimsandfacts You may find this useful - https://community.powerbi.com/t5/Community-Blog/To-bleep-With-Time-Intelligence/ba-p/1260000

Also, see if my Weather Intelligence the Hard Way provides a different way to achieve what you're looking for.

https://community.powerbi.com/t5/Quick-Measures-Gallery/Time-Intelligence-quot-The-Hard-Way-quot-TIT...


@ me in replies or I'll lose your thread!!!
Check out my External Tool for Power BI Desktop! Microsoft Hates Greg's Quick Measures
YouTube Channel! Microsoft Hates Greg
Check out my latest book!

Ashish_Mathur
Super User
Super User

Hi,

Create a calendar table and build a relationship from the CreationDate column of the Logs table to the Date column of the Calendar Table.  In the Calendar Table, write calculated column formulas to extract Year and Month.  Create slicers for Year and Month columns from the Calendar Table.  Select year as 2020 and Month as August.  Write these measures:

FTM = Count('Logs'[.id])
Previous month = calculate([ftm],previousmonth(calendar[date]))

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Helpful resources

Announcements
Power BI December 2021 Update_carousel 768x460.jpg

Check it Out!

Click here to read more about the December 2021 Updates!

User Group Leader Meeting January 768x460.png

Calling all User Group Leaders!

Don't miss the User Group Leader meetings on January, 24th & 25th, 2022.

Jan 2022 Dev Camp 768x460 copy.png

Power BI Dev Camp- January 27th, 2022

Mark your calendars and join us for our next Power BI Dev Camp!

Top Solution Authors
Top Kudoed Authors